Skip to content

Commit

Permalink
[C#] Additional changes to be able to compile files.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//depot/code/examples-v3/": change = 7531]
  • Loading branch information
Verequus committed Jan 26, 2011
1 parent c28f1c2 commit cff3960
Show file tree
Hide file tree
Showing 32 changed files with 175 additions and 6 deletions.
1 change: 1 addition & 0 deletions csharp/ANTLR/ANTLRv3.g
Expand Up @@ -81,6 +81,7 @@ tokens {
int gtype;
}
public
grammarDef
: DOC_COMMENT?
( 'lexer' {gtype=LEXER_GRAMMAR;} // pure lexer
Expand Down
1 change: 1 addition & 0 deletions csharp/ANTLR/ANTLRv3Tree.g
Expand Up @@ -36,6 +36,7 @@ options {
ASTLabelType = CommonTree;
}

public
grammarDef
: ^( grammarType ID DOC_COMMENT? optionsSpec? tokensSpec? attrScope* action* rule+ )
;
Expand Down
1 change: 1 addition & 0 deletions csharp/C/C.g
Expand Up @@ -73,6 +73,7 @@ bool isTypeName(string name)
}
}
public
translation_unit
scope Symbols; // entire file is a scope
@init {
Expand Down
1 change: 1 addition & 0 deletions csharp/LL-star/SimpleC.g
Expand Up @@ -5,6 +5,7 @@ options
language=CSharp2;
}

public
program
: declaration+
;
Expand Down
1 change: 1 addition & 0 deletions csharp/cminus/CMinus.g
Expand Up @@ -20,6 +20,7 @@ scope slist {
@header {
}

public
program
scope {
IList<StringTemplate> globals;
Expand Down
2 changes: 1 addition & 1 deletion csharp/cminus/Main.cs
Expand Up @@ -50,7 +50,7 @@ public static void Main(string[] args)
CommonTokenStream tokens = new CommonTokenStream(lexer);
CMinusParser parser = new CMinusParser(tokens);
parser.TemplateLib = templates;
RuleReturnScope r = parser.program();
CMinusParser.program_return r = parser.program();
Console.Out.WriteLine(r.Template.ToString());
}
else
Expand Down
1 change: 1 addition & 0 deletions csharp/composite-java/Java.g
Expand Up @@ -18,6 +18,7 @@ import JavaDecl, JavaAnnotations, JavaExpr, JavaStat, JavaLexerRules;
// starting point for parsing a java file
/* The annotations are separated out to make parsing faster, but must be associated with
a packageDeclaration or a typeDeclaration (and not an empty one). */
public
compilationUnit
: annotations
( packageDeclaration importDeclaration* typeDeclaration*
Expand Down
15 changes: 15 additions & 0 deletions csharp/composite-java/JavaAnnotations.g
Expand Up @@ -2,48 +2,59 @@ parser grammar JavaAnnotations;

// ANNOTATIONS

public
annotations
: annotation+
;

public
annotation
: '@' annotationName ( '(' ( elementValuePairs | elementValue )? ')' )?
;

public
annotationName
: Identifier ('.' Identifier)*
;

public
elementValuePairs
: elementValuePair (',' elementValuePair)*
;

public
elementValuePair
: Identifier '=' elementValue
;

public
elementValue
: conditionalExpression
| annotation
| elementValueArrayInitializer
;

public
elementValueArrayInitializer
: '{' (elementValue (',' elementValue)*)? (',')? '}'
;

public
annotationTypeDeclaration
: '@' 'interface' Identifier annotationTypeBody
;

public
annotationTypeBody
: '{' (annotationTypeElementDeclaration)* '}'
;

public
annotationTypeElementDeclaration
: modifiers annotationTypeElementRest
;

public
annotationTypeElementRest
: type annotationMethodOrConstantRest ';'
| normalClassDeclaration ';'?
Expand All @@ -52,19 +63,23 @@ annotationTypeElementRest
| annotationTypeDeclaration ';'?
;

public
annotationMethodOrConstantRest
: annotationMethodRest
| annotationConstantRest
;

public
annotationMethodRest
: Identifier '(' ')' defaultValue?
;

public
annotationConstantRest
: variableDeclarators
;

public
defaultValue
: 'default' elementValue
;

0 comments on commit cff3960

Please sign in to comment.