Skip to content

Commit

Permalink
Added more tuple functions and optional parentheses for tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobMisirian committed Oct 8, 2015
1 parent a644ac8 commit 8867363
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Hassium/HassiumObjects/HassiumTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private HassiumObject add(HassiumObject[] args)
private HassiumObject remove(HassiumObject[] args)
{
foreach (HassiumObject arg in args)
Attributes.Remove("Item" + ((HassiumInt)arg).Value);
Attributes.Remove(((HassiumString)arg).Value);

return null;
}
Expand Down
13 changes: 12 additions & 1 deletion src/Hassium/Parser/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ private static ArgListNode parseArgList(Parser parser)
if (!parser.AcceptToken(TokenType.Comma))
break;
}

parser.ExpectToken("Unterminated argument list", TokenType.RParen);

return ret;
Expand Down Expand Up @@ -601,7 +602,17 @@ private static AstNode parseTuple(Parser parser)

parser.ExpectToken(TokenType.Identifier, "tuple");
string name = parser.ExpectToken(TokenType.Identifier).Value.ToString();
AstNode body = parseArgList(parser);
parser.AcceptToken(TokenType.LParen, "(");

AstNode body = new CodeBlock(position);
while (!parser.AcceptToken(TokenType.RParen) && !parser.MatchToken(TokenType.EndOfLine))
{
body.Children.Add(parseExpression(parser));
if (!parser.AcceptToken(TokenType.Comma))
break;
}

parser.AcceptToken(TokenType.RParen);
parser.ExpectToken(TokenType.EndOfLine);
return new TupleNode(position, name, body);
}
Expand Down

0 comments on commit 8867363

Please sign in to comment.