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.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/Sencha-lang/Parser.cpp b/Sencha-lang/Parser.cpp
index 5721beb..e30e337 100644
--- a/Sencha-lang/Parser.cpp
+++ b/Sencha-lang/Parser.cpp
@@ -273,31 +273,37 @@ ASTStatement * Parser::statement(ASTNode * parent)
ASTExpression * Parser::prim_expr(ASTNode * expression)
{
- ConstantExpression * ce;
- BasicExpression * be;
- //TODO add reference type to prims, syblol is now just a literal... and floats
+
+
+
if(current_token.get_type() == t_integer)
{
report("Number: " + tok_value + "\n");
+ ConstantExpression * ce;
ce = new ConstantExpression(expression, std::atoi(tok_value.c_str()));
- read_next();
+ read_next();
+ return ce;
}
else if(current_token.get_type() == t_float)
{
report("Number: " + tok_value + "\n");
-
+ ConstantExpression * ce;
ce = new ConstantExpression(expression, std::atof(tok_value.c_str()));
read_next();
+ return ce;
}
else if(current_token.get_type() == t_literal)
{
report("Character literal: " + tok_value + "\n");
+ ConstantExpression * ce;
ce = new ConstantExpression(expression, tok_value);
- read_next();
+ read_next();
+ return ce;
}
else if(current_token.get_type() == t_keyword)
{
+ ConstantExpression * ce;
if(tok_value == "true")
{
report("Boolean: " + tok_value + "\n");
@@ -310,23 +316,22 @@ ASTExpression * Parser::prim_expr(ASTNode * expression)
ce = new ConstantExpression(expression, SenchaObject(false));
read_next();
}
+ return ce;
}
else if(current_token.get_type() == t_symbol)
{
report("variable: " + tok_value + "\n");
- SenchaObject variable;
- //TODO is it right?
string name = current_token.value;
- //variable = context->get(name);
- variable.name = name;
-
- ce = new ConstantExpression(expression, variable, context);
+ VariableExpression * ve;
+ ve = new VariableExpression(expression, context, name);
read_next();
+ return ve;
}
else if(accept("("))
{
- report("( ");
+ report("( ");
+ BasicExpression * be;
be = static_cast<BasicExpression *>(expr(expression));
report(" ) ");
expect(")");
@@ -340,7 +345,6 @@ ASTExpression * Parser::prim_expr(ASTNode * expression)
return new IncorrectExpression(expression, error_message);
}
- return ce;
}
ASTExpression * Parser::postfix_expr(ASTNode * expression)