diff --git a/lib/lexer.js b/lib/lexer.js index f7f732fb..396d2704 100644 --- a/lib/lexer.js +++ b/lib/lexer.js @@ -590,7 +590,7 @@ NUMBER = /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-]?[0-9]+)?)))\b/i; HEREDOC = /^("{6}|'{6}|"{3}\n?([\s\S]*?)\n?([ \t]*)"{3}|'{3}\n?([\s\S]*?)\n?([ \t]*)'{3})/; INTERPOLATION = /^\$([a-zA-Z_@]\w*(\.\w+)*)/; - OPERATOR = /^([+\*&|\/\-%=<>:!?]+)([ \t]*)/; + OPERATOR = /^(-[\-=>]?|\+[+=]?|[*&|\/%=<>:!?]+)([ \t]*)/; WHITESPACE = /^([ \t]+)/; COMMENT = /^(\s*#{3}(?!#)[ \t]*\n+([\s\S]*?)[ \t]*\n+[ \t]*#{3}|(\s*#[^\n]*)+)/; CODE = /^((-|=)>)/; diff --git a/src/lexer.coffee b/src/lexer.coffee index 994930f9..3cca3924 100644 --- a/src/lexer.coffee +++ b/src/lexer.coffee @@ -509,7 +509,7 @@ IDENTIFIER : /^([a-zA-Z\$_](\w|\$)*)/ NUMBER : /^(((\b0(x|X)[0-9a-fA-F]+)|((\b[0-9]+(\.[0-9]+)?|\.[0-9]+)(e[+\-]?[0-9]+)?)))\b/i HEREDOC : /^("{6}|'{6}|"{3}\n?([\s\S]*?)\n?([ \t]*)"{3}|'{3}\n?([\s\S]*?)\n?([ \t]*)'{3})/ INTERPOLATION : /^\$([a-zA-Z_@]\w*(\.\w+)*)/ -OPERATOR : /^([+\*&|\/\-%=<>:!?]+)([ \t]*)/ +OPERATOR : /^(-[\-=>]?|\+[+=]?|[*&|\/%=<>:!?]+)([ \t]*)/ WHITESPACE : /^([ \t]+)/ COMMENT : /^(\s*#{3}(?!#)[ \t]*\n+([\s\S]*?)[ \t]*\n+[ \t]*#{3}|(\s*#[^\n]*)+)/ CODE : /^((-|=)>)/ diff --git a/test/test_operations.coffee b/test/test_operations.coffee index 42427586..839743e6 100644 --- a/test/test_operations.coffee +++ b/test/test_operations.coffee @@ -49,4 +49,11 @@ ok 1 not in array list: [1, 2, 7] result: if list[2] in [7, 10] then 100 else -1 -ok result is 100 \ No newline at end of file +ok result is 100 + +# Non-spaced values still work. +x: 10 +y: -5 + +ok x*-y is 50 +ok x*+y is -50