Add boolean operators

pull/70/head
Max Brunsfeld 2014-08-04 18:46:38 +07:00
parent 825945d79a
commit bcce5504a8
2 changed files with 18 additions and 0 deletions

@ -97,6 +97,7 @@ module.exports = compiler.grammar
@member_access, @member_access,
@subscript_access, @subscript_access,
@function_call, @function_call,
@bool_op,
@math_op, @math_op,
@rel_op, @rel_op,
@assignment, @assignment,
@ -161,6 +162,10 @@ module.exports = compiler.grammar
/\d+/, /\d+/,
optional(seq(".", /\d+/)))) optional(seq(".", /\d+/))))
bool_op: -> choice(
seq(@expression, "&&", @expression),
seq(@expression, "||", @expression))
math_op: -> choice( math_op: -> choice(
seq(@expression, "++"), seq(@expression, "++"),
seq(@expression, "--"), seq(@expression, "--"),

@ -171,6 +171,19 @@ i - j;
(expression_statement (math_op (identifier) (identifier))) (expression_statement (math_op (identifier) (identifier)))
(expression_statement (math_op (identifier) (identifier)))) (expression_statement (math_op (identifier) (identifier))))
============================================
Boolean operators
============================================
i || j;
i && j;
---
(program
(expression_statement (bool_op (identifier) (identifier)))
(expression_statement (bool_op (identifier) (identifier))))
============================================ ============================================
Relational operators Relational operators
============================================ ============================================