Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prefix operator ones_complement is added.

Rule stmt_return is improved.
  • Loading branch information...
commit dc0d4b7d95a84b79c6f4c27c2a5605e5e73f85c8 1 parent eef5c56
Maksym Trushyn authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/Boo.TinyAst/TinyAstEvaluator.boo
8 src/Boo.TinyAst/TinyAstEvaluator.boo
View
@@ -56,6 +56,7 @@ ometa TinyAstEvaluator(compilerParameters as CompilerParameters):
decrement = "--"
plus = "+"
minus = "-"
+ ones_complement = "~"
star = "*"
division = "/"
modulus = "%"
@@ -483,7 +484,7 @@ ometa TinyAstEvaluator(compilerParameters as CompilerParameters):
declaration = optional_type >> typeRef, id >> name ^ newDeclaration(name, typeRef)
prefix_expression = Prefix(IsPostfix: _ >> p and (p == false), Operator: prefix_operator >> op, Operand: assignment >> e) ^ newPrefixExpression(op, e)
- prefix_operator = NOT | MINUS | INCREMENT | DECREMENT | STAR
+ prefix_operator = NOT | MINUS | INCREMENT | DECREMENT | STAR | ONES_COMPLEMENT
invocation = here >> i, (collection_initialization | invocation_expression) >> e, ~_, next[i] ^ e
invocation_expression = here >> i, member_reference_left >> mr, prefix_operand[invocation_arguments] >> args \
@@ -612,7 +613,8 @@ ometa TinyAstEvaluator(compilerParameters as CompilerParameters):
macro_id = Identifier(Name: _ >> name, IsKeyword: _ >> k and (k == false)) ^ name
- stmt_return = here >> i, (RETURN | (prefix[RETURN], (assignment >> e | (prefix[assignment] >> e, stmt_modifier >> m) | block_expression >> e ) ) ), next[i] ^ ReturnStatement(Expression: e, Modifier: m)
+ stmt_return = here >> i, prefix_or_rule[RETURN], ( (optional_rule_or_prefix[assignment] >> e, optional[stmt_modifier] >> m, nothing) | optional[block_expression] >> e )\
+ , next[i] ^ ReturnStatement(Expression: e, Modifier: m)
stmt_raise = here >> i, prefix[RAISE], (expression >> e | (prefix[expression] >> e, stmt_modifier >> m)), next[i] ^ RaiseStatement(Exception: e, Modifier: m)
@@ -677,6 +679,8 @@ ometa TinyAstEvaluator(compilerParameters as CompilerParameters):
optional_prefix_or_rule[rule] = (Prefix(Operator: rule >> e, Operand: _ >> newInput), $(success(newInput, e))) | optional[rule]
+ optional_rule_or_prefix[rule] = rule | (Prefix(Operator: (rule >> e), Operand: _ >> newInput), $(success(newInput, e))) | ""
+
prefix_or_rule[rule] = (Prefix(Operator: rule >> e, Operand: _ >> newInput), $(success(newInput, e))) | rule
rule_or_prefix[rule] = (Prefix(Operator: rule >> e, Operand: _ >> newInput), $(success(newInput, e))) | rule
Please sign in to comment.
Something went wrong with that request. Please try again.