aboutsummaryrefslogtreecommitdiff
path: root/runtime/CSharp3/Sources/Antlr3.Runtime.Test/TestActionFeatures.g3
blob: 174526f33f31311f9a21ff5df72e3c786ce33eb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
grammar TestActionFeatures;

options {
    language=CSharp3;
    TokenLabelType=CommonToken;
    output=AST;
    ASTLabelType=CommonTree;
}

@lexer::namespace{Antlr3.Runtime.Test}
@parser::namespace{Antlr3.Runtime.Test}

@parser::header{using Console = System.Console;}

/*
 * Parser Rules
 */

public
compileUnit
    :   EOF
    ;

// SET_DYNAMIC_SCOPE_ATTR

setDynamicScopeAttr
scope {int i;}
	:	EOF {$setDynamicScopeAttr::i=3; $setDynamicScopeAttr[0]::i=3; $setDynamicScopeAttr[-0]::i=3;}
	;

// DYNAMIC_SCOPE_ATTR

dynamicScopeAttr
scope {int i;}
	:	EOF {Console.WriteLine($dynamicScopeAttr::i);}
	;

// DYNAMIC_NEGATIVE_INDEXED_SCOPE_ATTR

dynamicNegativeIndexedScopeAttr
scope {int i;}
	:	EOF {Console.WriteLine($dynamicNegativeIndexedScopeAttr[-1]::i);}
	;

// DYNAMIC_ABSOLUTE_INDEXED_SCOPE_ATTR

dynamicAbsoluteIndexedScopeAttr
scope {int i;}
	:	EOF {Console.WriteLine($dynamicNegativeIndexedScopeAttr[0]::i);}
	;

// ISOLATED_DYNAMIC_SCOPE

isolatedDynamicScope
scope {int i;}
	:	EOF {Console.WriteLine($isolatedDynamicScope.Count);}
	;

/*
 * Lexer Rules
 */

WS
    :   ' '
    ;