TestActionFeatures.g3 revision 324c4644fee44b9898524c09511bd33c3f12e2df
1grammar TestActionFeatures;
2
3options {
4    language=CSharp3;
5    TokenLabelType=CommonToken;
6    output=AST;
7    ASTLabelType=CommonTree;
8}
9
10@lexer::namespace{Antlr3.Runtime.Test}
11@parser::namespace{Antlr3.Runtime.Test}
12
13@parser::header{using Console = System.Console;}
14
15/*
16 * Parser Rules
17 */
18
19public
20compileUnit
21    :   EOF
22    ;
23
24// SET_DYNAMIC_SCOPE_ATTR
25
26setDynamicScopeAttr
27scope {int i;}
28	:	EOF {$setDynamicScopeAttr::i=3; $setDynamicScopeAttr[0]::i=3; $setDynamicScopeAttr[-0]::i=3;}
29	;
30
31// DYNAMIC_SCOPE_ATTR
32
33dynamicScopeAttr
34scope {int i;}
35	:	EOF {Console.WriteLine($dynamicScopeAttr::i);}
36	;
37
38// DYNAMIC_NEGATIVE_INDEXED_SCOPE_ATTR
39
40dynamicNegativeIndexedScopeAttr
41scope {int i;}
42	:	EOF {Console.WriteLine($dynamicNegativeIndexedScopeAttr[-1]::i);}
43	;
44
45// DYNAMIC_ABSOLUTE_INDEXED_SCOPE_ATTR
46
47dynamicAbsoluteIndexedScopeAttr
48scope {int i;}
49	:	EOF {Console.WriteLine($dynamicNegativeIndexedScopeAttr[0]::i);}
50	;
51
52// ISOLATED_DYNAMIC_SCOPE
53
54isolatedDynamicScope
55scope {int i;}
56	:	EOF {Console.WriteLine($isolatedDynamicScope.Count);}
57	;
58
59/*
60 * Lexer Rules
61 */
62
63WS
64    :   ' '
65    ;
66