diff options
Diffstat (limited to 'src/parser.y')
-rw-r--r-- | src/parser.y | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/parser.y b/src/parser.y index 95bd00d..ef9d10b 100644 --- a/src/parser.y +++ b/src/parser.y | |||
@@ -35,6 +35,7 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, const char *error ) | |||
35 | %} | 35 | %} |
36 | 36 | ||
37 | %token tokGame | 37 | %token tokGame |
38 | %token tokGlobal | ||
38 | %token tokFunction | 39 | %token tokFunction |
39 | %token tokSituation | 40 | %token tokSituation |
40 | %token tokSetup | 41 | %token tokSetup |
@@ -78,22 +79,26 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, const char *error ) | |||
78 | %left '-' '+' | 79 | %left '-' '+' |
79 | 80 | ||
80 | %% | 81 | %% |
81 | input: gameDecl bodyDecl | 82 | input: gameDecls globalDecl bodyDecl |
82 | ; | 83 | ; |
83 | 84 | ||
84 | gameDecl: tokGame '{' gameExprList '}' | 85 | gameDecls: |
86 | | gameDecls tokGame '.' tokIdent '=' literal ';' | ||
87 | ; | ||
88 | |||
89 | globalDecl: tokGlobal '{' globalExprList '}' | ||
85 | ; | 90 | ; |
86 | 91 | ||
87 | gameExprList: | 92 | globalExprList: |
88 | | gameExprList cmpltGameExpr | 93 | | globalExprList cmpltGlobalExpr |
89 | ; | 94 | ; |
90 | 95 | ||
91 | cmpltGameExpr: gameExpr ';' | 96 | cmpltGlobalExpr: globalExpr ';' |
92 | | commandDecl | 97 | | commandDecl |
93 | ; | 98 | ; |
94 | 99 | ||
95 | gameExpr: tokIdent '=' expr | 100 | globalExpr: tokIdent '=' expr |
96 | ; | 101 | ; |
97 | 102 | ||
98 | bodyDecl: | 103 | bodyDecl: |
99 | | bodyDecl situation | 104 | | bodyDecl situation |
@@ -137,11 +142,15 @@ varRef: tokIdent | |||
137 | | tokSituation '.' tokIdent | 142 | | tokSituation '.' tokIdent |
138 | ; | 143 | ; |
139 | 144 | ||
140 | expr: tokInt | 145 | literal: tokInt |
141 | | tokFloat | 146 | | tokFloat |
142 | | tokString | 147 | | tokString |
143 | | tokBool | 148 | | tokBool |
144 | | tokNull | 149 | | tokNull |
150 | | tokSituationName | ||
151 | ; | ||
152 | |||
153 | expr: literal | ||
145 | | tokIdent '(' listValues ')' | 154 | | tokIdent '(' listValues ')' |
146 | | varRef | 155 | | varRef |
147 | | varRef '=' expr | 156 | | varRef '=' expr |
@@ -149,7 +158,6 @@ expr: tokInt | |||
149 | | varRef tokMinusAssign expr | 158 | | varRef tokMinusAssign expr |
150 | | varRef tokTimesAssign expr | 159 | | varRef tokTimesAssign expr |
151 | | varRef tokDivideAssign expr | 160 | | varRef tokDivideAssign expr |
152 | | tokSituationName | ||
153 | | expr '+' expr | 161 | | expr '+' expr |
154 | | expr '-' expr | 162 | | expr '-' expr |
155 | | expr '/' expr | 163 | | expr '/' expr |