Fixed several errors

This commit is contained in:
Hackerpilot 2013-04-22 23:01:03 -07:00
parent 461893dee3
commit 343e206b46
1 changed files with 15 additions and 10 deletions

25
D.g4
View File

@ -192,9 +192,9 @@ fragment OctalDigit: [0-7];
fragment BinDigit: [01]; fragment BinDigit: [01];
fragment DecimalDigit: [0-9]; fragment DecimalDigit: [0-9];
fragment BlockComment: '/*' (Character | Whitespace)* '*/'; fragment BlockComment: '/*' .*? '*/';
fragment LineComment: '//' (~[\r\n])* EndOfLine; fragment LineComment: '//' (~[\r\n])* EndOfLine;
fragment NestingBlockComment: '/+' (NestingBlockComment | Character*) '+/'; fragment NestingBlockComment: '/+' (NestingBlockComment | .)* '+/';
Comment : (BlockComment | LineComment | NestingBlockComment) -> skip; Comment : (BlockComment | LineComment | NestingBlockComment) -> skip;
Identifier : ([a-zA-Z_])([a-zA-Z0-9_])*; Identifier : ([a-zA-Z_])([a-zA-Z0-9_])*;
@ -227,7 +227,7 @@ fragment HexString: 'x"' HexStringChar* '"' StringPostfix?;
// fragment TokenString: 'q{' Token* '}'; // fragment TokenString: 'q{' Token* '}';
StringLiteral : WysiwygString | AlternativeWysiwygString | DoubleQuotedString | HexString /*| DelimitedString | TokenString*/; StringLiteral : WysiwygString | AlternativeWysiwygString | DoubleQuotedString | HexString /*| DelimitedString | TokenString*/;
CharacterLiteral: '\'' (Character | EscapeSequence) '\''; CharacterLiteral: '\'' ( EscapeSequence | ~[\\'] )*? '\'';
IntegerLiteral: Integer IntegerSuffix?; IntegerLiteral: Integer IntegerSuffix?;
fragment Integer: BinaryInteger | DecimalInteger | HexadecimalInteger; fragment Integer: BinaryInteger | DecimalInteger | HexadecimalInteger;
@ -271,6 +271,7 @@ declaration: attributedDeclaration
| staticDestructor | staticDestructor
| sharedStaticDestructor | sharedStaticDestructor
| sharedStaticConstructor | sharedStaticConstructor
| conditionalDeclaration
; ;
importDeclaration: 'static'? 'import' importList ';' importDeclaration: 'static'? 'import' importList ';'
@ -330,6 +331,7 @@ nonemptyStatement: nonEmptyStatementNoCaseNoDefault
; ;
nonEmptyStatementNoCaseNoDefault: labeledStatement nonEmptyStatementNoCaseNoDefault: labeledStatement
| blockStatement
| assignStatement | assignStatement
| ifStatement | ifStatement
| whileStatement | whileStatement
@ -898,10 +900,7 @@ blockStatement: '{' declarationsAndStatements? '}'
declarationsAndStatements: (declaration | statement)+ declarationsAndStatements: (declaration | statement)+
; ;
functionDeclaration: type Identifier parameters (functionBody | ';') functionDeclaration: type Identifier (templateParameters? parameters constraint? functionBody | parameters (functionBody | ';'))
;
functionTemplateDeclaration: type Identifier templateParameters parameters constraint? functionBody
; ;
type: typeConstructors? type2 type: typeConstructors? type2
@ -912,10 +911,10 @@ type2: type3 typeSuffix?
; ;
type3: builtinType type3: builtinType
| '.' identifierChain | '.' identifierOrTemplateChain
| identifierChain | identifierOrTemplateChain
| typeof | typeof
| typeof '.' identifierChain | typeof '.' identifierOrTemplateChain
| 'const' '(' type ')' | 'const' '(' type ')'
| 'immutable' '(' type ')' | 'immutable' '(' type ')'
| 'shared' '(' type ')' | 'shared' '(' type ')'
@ -924,6 +923,9 @@ type3: builtinType
| 'function' parameters memberFunctionAttributes? | 'function' parameters memberFunctionAttributes?
; ;
identifierOrTemplateChain : identifierOrTemplateInstance ('.' identifierOrTemplateInstance)*
;
typeSuffix: '*' typeSuffix: '*'
| '[' ']' | '[' ']'
| '[' type ']' | '[' type ']'
@ -1103,6 +1105,9 @@ sharedStaticDestructor: 'shared' 'static' 'this' '(' ')' functionBody
sharedStaticConstructor: 'shared' 'static' '~' 'this' '(' ')' functionBody sharedStaticConstructor: 'shared' 'static' '~' 'this' '(' ')' functionBody
; ;
conditionalDeclaration: compileCondition (declaration | '{' declaration* '}')
;
invariant: 'invariant' '(' ')' blockStatement invariant: 'invariant' '(' ')' blockStatement
; ;