Diff
Not logged in

Differences From Artifact [9df8a8a07696ff22]:

To Artifact [b6858e7b65012cb1]:


152 // [TODO] make this customizable from program 152 // [TODO] make this customizable from program 153 private static string[][] operator_perferences = [ 153 private static string[][] operator_perferences = [ 154 ["||"], 154 ["||"], 155 ["&&"], 155 ["&&"], 156 ["!="], 156 ["!="], 157 ["=="], 157 ["=="], 158 ["<","<=",">",">="], 158 ["<","<=",">",">="], 159 ["|"], | 159 // ["|"], 160 ["^"], | 160 // ["^"], 161 ["&"], | 161 // ["&"], 162 ["<<", ">>"], | 162 // ["<<", ">>", "<<<", ">>>"], 163 ["+","-"], 163 ["+","-"], 164 ["~"], 164 ["~"], 165 ["*","/","%"], 165 ["*","/","%"], 166 ["^^","**"], | 166 // ["^^","**"], 167 [".",".?"] 167 [".",".?"] 168 ]; 168 ]; 169 169 170 AST E(size_t level) 170 AST E(size_t level) 171 { 171 { 172 /// Expression ::= (Binary left-associative operators over) Func 172 /// Expression ::= (Binary left-associative operators over) Func 173 173 ................................................................................................................................................................................ 192 return Funcall(); 192 return Funcall(); 193 else 193 else 194 return rec(E(level+1)); 194 return rec(E(level+1)); 195 } 195 } 196 196 197 AST Funcall() 197 AST Funcall() 198 { 198 { 199 /// Funcall ::= BaseExpression ["(" Expression%"," ")"]* | 199 /// Funcall ::= BaseExpression ["(" Expression%"," ")" | "{" ENT 200 200 201 auto e = BaseExpression(); 201 auto e = BaseExpression(); 202 for(;;) 202 for(;;) 203 if( tryEat("(") ) 203 if( tryEat("(") ) 204 { 204 { 205 auto pos = currentPosition(); 205 auto pos = currentPosition(); 206 AST[] args; 206 AST[] args; ................................................................................................................................................................................ 222 else 222 else 223 break; 223 break; 224 return e; 224 return e; 225 } 225 } 226 226 227 AST parseTableSetAfterBrace(AST e) 227 AST parseTableSetAfterBrace(AST e) 228 { 228 { > 229 /// TableSet ::= "{" (ID ":" E) % "," "}" > 230 229 if( tryEat("}") ) 231 if( tryEat("}") ) 230 return e; 232 return e; 231 auto pos = currentPosition(); 233 auto pos = currentPosition(); 232 for(;;) 234 for(;;) 233 { 235 { 234 string key = eatId("for table key", AllowQuoted); 236 string key = eatId("for table key", AllowQuoted); 235 eat(":", "after table key"); 237 eat(":", "after table key"); ................................................................................................................................................................................ 314 } 316 } 315 scope(exit) lex.popFront; 317 scope(exit) lex.popFront; 316 return new Var(pos, lex.front.str); 318 return new Var(pos, lex.front.str); 317 } 319 } 318 320 319 AST parsePatternMatch(LexPosition pos) 321 AST parsePatternMatch(LexPosition pos) 320 { 322 { 321 // case( pmExpr )cases | 323 // case "(" pmExpr ")" CASES 322 //==> 324 //==> 323 // let pmVar = pmExpr in (... let pmTryFirst = ... in pmTryFir 325 // let pmVar = pmExpr in (... let pmTryFirst = ... in pmTryFir 324 eat("(", "after case"); 326 eat("(", "after case"); 325 AST pmExpr = E(0); 327 AST pmExpr = E(0); 326 eat(")", "after case"); 328 eat(")", "after case"); 327 string pmVar = freshVarName(); 329 string pmVar = freshVarName(); 328 string pmTryFirst = freshVarName(); 330 string pmTryFirst = freshVarName(); ................................................................................................................................................................................ 657 case( 1 ) 659 case( 1 ) 658 when(x){1} 660 when(x){1} 659 `)); 661 `)); 660 assert_nothrow(parseString(` 662 assert_nothrow(parseString(` 661 case( 1 ) 663 case( 1 ) 662 when({aaaa:_}){1} 664 when({aaaa:_}){1} 663 `)); 665 `)); > 666 assert_nothrow(parseString(` > 667 case( 1 ) > 668 when({aaaa:@value(x)}){1} > 669 when({aaaa:{bbb:_}, ccc:123}){1} > 670 `)); 664 } 671 }