summaryrefslogtreecommitdiff
path: root/src/parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/parser.y b/src/parser.y
index 707d85d..3dfd737 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -155,7 +155,19 @@ cmpltExpr: expr ';'
155 | tokReturn '(' ')' ';' { bld.addNode( AstNode::tReturn ); } 155 | tokReturn '(' ')' ';' { bld.addNode( AstNode::tReturn ); }
156 | tokGoto '(' expr ')' ';' { bld.addNode( AstNode::tGoto ); } 156 | tokGoto '(' expr ')' ';' { bld.addNode( AstNode::tGoto ); }
157 | ifbase 157 | ifbase
158 | tokFor tokEach forIterator tokIn expr tokDo '{' cmpltExprList '}' 158 | tokFor tokEach {
159 bld.addNode( AstNode::tForEach );
160 bld.addNode( AstNode::tScope );
161 } forIterator tokIn {
162 bld.closeNode();
163 bld.addNode( AstNode::tScope );
164 } expr tokDo '{' {
165 bld.closeNode();
166 bld.addNode( AstNode::tScope );
167 } cmpltExprList '}' {
168 bld.closeNode();
169 bld.closeNode();
170 }
159 | tokWhile { 171 | tokWhile {
160 bld.addNode( AstNode::tWhile ); 172 bld.addNode( AstNode::tWhile );
161 bld.addNode( AstNode::tScope ); 173 bld.addNode( AstNode::tScope );
@@ -168,8 +180,12 @@ cmpltExpr: expr ';'
168 } 180 }
169 ; 181 ;
170 182
171forIterator: tokIdent 183forIterator: tokIdent { bld.addVarRef( *($1), sidLocal ); }
172 | tokIdent ':' tokIdent 184 | tokIdent ':' tokIdent {
185 bld.addVarRef( *($1), sidLocal );
186 bld.addVarRef( *($3), sidLocal );
187 }
188 ;
173 189
174ifbase: tokIf { 190ifbase: tokIf {
175 bld.addNode( AstNode::tIf ); 191 bld.addNode( AstNode::tIf );
@@ -226,7 +242,8 @@ expr: literal
226 | expr tokLtEq expr { bld.addNode( AstNode::tCompLtEq ); } 242 | expr tokLtEq expr { bld.addNode( AstNode::tCompLtEq ); }
227 | expr tokGtEq expr { bld.addNode( AstNode::tCompGtEq ); } 243 | expr tokGtEq expr { bld.addNode( AstNode::tCompGtEq ); }
228 | '(' expr ')' 244 | '(' expr ')'
229 | expr '[' expr ']' 245 | expr '[' expr ']' { bld.addNode( AstNode::tIndex ); }
246 | expr '[' expr ']' '=' expr { bld.addNode( AstNode::tInsert ); }
230 | '[' ']' { bld.addLiteral( Variable( Variable::tList ) ); } 247 | '[' ']' { bld.addLiteral( Variable( Variable::tList ) ); }
231 | '[' { bld.addLiteral( Variable( Variable::tList ) ); } listValues ']' 248 | '[' { bld.addLiteral( Variable( Variable::tList ) ); } listValues ']'
232 | '{' '}' { bld.addLiteral( Variable( Variable::tDictionary ) ); } 249 | '{' '}' { bld.addLiteral( Variable( Variable::tDictionary ) ); }