Check-in [6ecc7046fc]
Not logged in
Overview
SHA1 Hash:6ecc7046fcdc27e87af8a373c493df634067d842
Date: 2010-11-21 17:33:47
User: kinaba
Comment:tableset x{y:1} expression added
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified polemy/parse.d from [a024e7c2d40e70c4] to [25ec86a59533b939].

193 } 193 } 194 194 195 AST Funcall() 195 AST Funcall() 196 { 196 { 197 /// Funcall ::= BaseExpression ["(" Expression%"," ")"]* 197 /// Funcall ::= BaseExpression ["(" Expression%"," ")"]* 198 198 199 auto e = BaseExpression(); 199 auto e = BaseExpression(); > 200 for(;;) 200 while( tryEat("(") ) | 201 if( tryEat("(") ) 201 { | 202 { 202 auto pos = currentPosition(); | 203 auto pos = currentPosition(); 203 AST[] args; | 204 AST[] args; 204 while( !tryEat(")") ) { | 205 while( !tryEat(")") ) { 205 if( lex.empty ) | 206 if( lex.empty ) 206 throw genex!UnexpectedEOF(pos, "closing | 207 throw genex!UnexpectedEOF(pos, " 207 args ~= E(0); | 208 args ~= E(0); 208 if( !tryEat(",") ) { | 209 if( !tryEat(",") ) { 209 eat(")", "after function parameters"); | 210 eat(")", "after function paramet 210 break; | 211 break; > 212 } 211 } 213 } > 214 e = new FuncallExpression(e.pos, e, args); > 215 } > 216 else if( tryEat("{") ) > 217 { > 218 e = parseTableSetAfterBrace(e); 212 } 219 } > 220 else > 221 break; > 222 return e; > 223 } > 224 > 225 AST parseTableSetAfterBrace(AST e) > 226 { > 227 if( tryEat("}") ) > 228 return e; > 229 auto pos = currentPosition(); > 230 for(;;) > 231 { > 232 string key = eatId("for table key", AllowQuoted); > 233 eat(":", "after table key"); > 234 AST val = E(0); 213 e = new FuncallExpression(e.pos, e, args); | 235 e = new FuncallExpression(pos, new VarExpression(pos,".= > 236 e, new StrLiteral(pos,key), val); > 237 if( !tryEat(",") ) > 238 { > 239 eat("}", "for the end of table literal"); > 240 break; > 241 } 214 } 242 } 215 return e; 243 return e; 216 } 244 } 217 245 218 AST BaseExpression() 246 AST BaseExpression() 219 { 247 { 220 if( lex.empty ) 248 if( lex.empty ) ................................................................................................................................................................................ 244 auto e = Body(); 272 auto e = Body(); 245 eat(")", "after parenthesized expression"); 273 eat(")", "after parenthesized expression"); 246 return e; 274 return e; 247 } 275 } 248 if( tryEat("{") ) 276 if( tryEat("{") ) 249 { 277 { 250 AST e = new FuncallExpression(pos, new VarExpression(pos 278 AST e = new FuncallExpression(pos, new VarExpression(pos 251 if( tryEat("}") ) | 279 return parseTableSetAfterBrace(e); 252 return e; < 253 for(;;) < 254 { < 255 string key = eatId("for table key", AllowQuoted) < 256 eat(":", "after table key"); < 257 AST val = E(0); < 258 e = new FuncallExpression(pos, new VarExpression < 259 e, new StrLiteral(pos,key), val) < 260 if( !tryEat(",") ) < 261 { < 262 eat("}", "for the end of table literal") < 263 break; < 264 } < 265 } < 266 return e; < 267 } 280 } 268 if( tryEat("if") ) 281 if( tryEat("if") ) 269 { 282 { 270 eat("(", "after if"); 283 eat("(", "after if"); 271 auto cond = E(0); 284 auto cond = E(0); 272 eat(")", "after if condition"); 285 eat(")", "after if condition"); 273 auto thenPos = lex.front.pos; 286 auto thenPos = lex.front.pos; ................................................................................................................................................................................ 465 let("@type", "(system)", fun(["x"], var("x")), var("@type")) ); 478 let("@type", "(system)", fun(["x"], var("x")), var("@type")) ); 466 479 467 assert_eq(parseString(`{}`), call(var("{}"))); 480 assert_eq(parseString(`{}`), call(var("{}"))); 468 assert_eq(parseString(`{foo:1,"bar":2}`), 481 assert_eq(parseString(`{foo:1,"bar":2}`), 469 call(var(".="), call(var(".="), call(var("{}")), strl("foo"), in 482 call(var(".="), call(var(".="), call(var("{}")), strl("foo"), in 470 assert_eq(parseString(`{}.foo`), call(var("."),call(var("{}")),strl("foo 483 assert_eq(parseString(`{}.foo`), call(var("."),call(var("{}")),strl("foo 471 assert_eq(parseString(`{}.?foo`), call(var(".?"),call(var("{}")),strl("f 484 assert_eq(parseString(`{}.?foo`), call(var(".?"),call(var("{}")),strl("f > 485 assert_eq(parseString(`x{y:1}`), call(var(".="),var("x"),strl("y"),intl( 472 } 486 }

Modified tricks/test.d from [b9b84a35fccc5116] to [3ba75b9c3bef69b2].

100 assert_throw!AssertError( assert_throw!Error(nothing()) ); 100 assert_throw!AssertError( assert_throw!Error(nothing()) ); 101 assert_nothrow ( assert_throw!Error(assertError()) ); 101 assert_nothrow ( assert_throw!Error(assertError()) ); 102 assert_throw!AssertError( assert_throw!AssertError(error()) ); 102 assert_throw!AssertError( assert_throw!AssertError(error()) ); 103 } 103 } 104 104 105 template assertOp(string op) 105 template assertOp(string op) 106 { 106 { 107 void assertOp(A, B, string fn=__FILE__, size_t ln=__LINE__)(A a, B b, st | 107 void assertOp(A, B, string fn=__FILE__, size_t ln=__LINE__)(lazy A a_, l 108 { 108 { 109 try 109 try 110 { if( mixin("a"~op~"b") ) return; } | 110 { A a=a_(); B b=b_(); if( mixin("a"~op~"b") ) return; > 111 onAssertErrorMsg(fn, ln, msg.length ? msg : text(a, " 111 catch(Throwable e) 112 catch(Throwable e) 112 { onAssertErrorMsg(fn, ln, msg.length ? msg : "bad excep 113 { onAssertErrorMsg(fn, ln, msg.length ? msg : "bad excep 113 onAssertErrorMsg(fn, ln, msg.length ? msg : text(a, " !", op, " | 114 assert(false); 114 } 115 } 115 } 116 } 116 117 117 alias assertOp!(`==`) assert_eq; /// asserts two operands are == 118 alias assertOp!(`==`) assert_eq; /// asserts two operands are == 118 alias assertOp!(`!=`) assert_ne; /// asserts two operands are != 119 alias assertOp!(`!=`) assert_ne; /// asserts two operands are != 119 alias assertOp!(`<`) assert_lt; /// asserts two operands are < 120 alias assertOp!(`<`) assert_lt; /// asserts two operands are < 120 alias assertOp!(`<=`) assert_le; /// asserts two operands are <= 121 alias assertOp!(`<=`) assert_le; /// asserts two operands are <=