-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranche.y
31 lines (24 loc) · 962 Bytes
/
tranche.y
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
%namespace SyntaxAnalysis
%visibility internal
%using LexicalAnalysis;
%using AbstractSyntaxTree;
%using tc;
%start program
%YYSTYPE SemanticValue
/* Terminals */
%token<Token> RPAREN LBRACE RBRACE RBRACKET PBRACKET DOT DOTDOT COMMA IN TINT TREAL
%token<Token> TSTRING TBOOL TVOID TCHAR TFILE TSET TLIST FOR IF ELSE CLASS
%token<Token> NEW RETURN TRUE FALSE LITERAL_INT LITERAL_REAL LITERAL_STRING LITERAL_CHAR IDENTIFIER
/* Precedence rules */
%right ASSIGN
%left OR AND INCREMENT DECREMENT EXP
%left SMALLER GREATER SMEQ GTEQ EQ NEQ
%left PLUS MINUS TIMES DIVIDE MOD
%left UMINUS LPAREN NOT LBRACKET
%nonassoc ELSE
/* Non-terminal types */
program : typeList { SyntaxTreeRoot = $$; $$.Location = CurrentLocationSpan; }
;
typeDecList : { $$ = new ASTStatementList(); $$.Location = CurrentLocationSpan; }
| typeDec typeDecList { $$ = new ASTStatementList($1, $2); $$.Location = CurrentLocationSpan; }
;