summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/Parser.cpp')
-rw-r--r--Sencha-lang/Parser.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/Sencha-lang/Parser.cpp b/Sencha-lang/Parser.cpp
index e410cfb..157f59a 100644
--- a/Sencha-lang/Parser.cpp
+++ b/Sencha-lang/Parser.cpp
@@ -259,11 +259,7 @@ ASTExpression * Parser::postfix_expr()
if(!accept(")"))
{
function_call->add_argument(expr());
- while(accept(","))
- {
- function_call->add_argument(expr());
-
- }
+ while(accept(",")) function_call->add_argument(expr());
expect(")");
}
return function_call;
@@ -272,9 +268,20 @@ ASTExpression * Parser::postfix_expr()
return prim_expr();
}
+ASTExpression * Parser::unary_expr()
+{
+ if(peek("-") || peek("!"))
+ {
+ string oper = tok_value;
+ read_next();
+ return new UnaryExpression(unary_expr(), oper);
+ }
+ else return postfix_expr();
+}
+
ASTExpression * Parser::mul_expr()
{
- ASTExpression * left = postfix_expr();
+ ASTExpression * left = unary_expr();
if(peek("*") || peek("/"))
{
string oper = tok_value;