foo = {
$foo : 1 + 1,
"stuff" : 2 + 2,
- $bar : 3 + 3
+ $bar : 3 + 3,
}
print( foo[$bar] )
# List
foo = ()
+foo = (1,)
foo = (1,2,3)
foo = foo[1]
foo = (1,2,3,4,5)[2]
@ if [
(E B B) : exec_if($1, $2, $3),
- (E B) : exec_if($1, $2)
+ (E B) : exec_if($1, $2),
]
if (1 < 2)
// MapLiteral = '{' (Literal ':' LogicalExpr)* '}'
AST* DLParser::MapLiteral(void)
{
- AST* ret = NULL;
+ AST* ret = _new AST(MAP);
AST* child = NULL;
try
{
match(LBRACE);
do
{
- if( lookaheadType(1) == COMMA ) consume();
-
child = Literal();
match(SEP);
child = _new AST(SEP, 2, child, LogicalExpr());
-
- ret = ((ret == NULL) ? _new AST(MAP) : ret);
ret->addChild(child);
+
+ if( lookaheadType(1) == COMMA ) consume();
}
- while( lookaheadType(1) == COMMA );
+ while( lookaheadType(1) != RBRACE );
match(RBRACE);
}
catch(Exception e)
{
- if(ret != NULL) delete ret;
+ // Cleanup our mess so we dont leak memory
+ delete ret;
if(child != NULL) delete child;
+
+ // Re throw the exception so higher-ups can handle it
throw e;
}
return ret;
std::list<Pattern> patterns;
patterns.push_back( MacroPattern() );
- while(lookaheadType(1) == COMMA)
+ while (lookaheadType(1) != RBRACK)
{
- match(COMMA);
- patterns.push_back( MacroPattern() );
+ if ( lookaheadType(1) == COMMA )
+ {
+ consume();
+ if (lookaheadType(1) != RBRACK)
+ {
+ patterns.push_back( MacroPattern() );
+ }
+ }
}
return patterns;
if(lookaheadType(1) != terminator)
{
node->addChild( Expression() );
- while(lookaheadType(1) == COMMA)
+ while(lookaheadType(1) != terminator)
{
- match(COMMA);
- node->addChild( Expression() );
+ if ( lookaheadType(1) == COMMA )
+ {
+ consume();
+ if (lookaheadType(1) != terminator)
+ {
+ node->addChild( Expression() );
+ }
+ }
}
}
return node;