Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support negative number literals

  • Loading branch information...
commit 4ebc0697f6893afb597587e48ea8040699ec6a57 1 parent 6a9845f
Evan Miller evanmiller authored
Showing with 6 additions and 0 deletions.
  1. +4 −0 src/erlydtl_scanner.erl
  2. +2 −0  tests/src/erlydtl_unittests.erl
4 src/erlydtl_scanner.erl
View
@@ -251,6 +251,8 @@ scan([H | T], Scanned, {Row, Column}, {in_code, Closer}) ->
case char_type(H) of
letter_underscore ->
scan(T, [{identifier, {Row, Column}, [H]} | Scanned], {Row, Column + 1}, {in_identifier, Closer});
+ hyphen_minus ->
+ scan(T, [{number_literal, {Row, Column}, [H]} | Scanned], {Row, Column + 1}, {in_number, Closer});
digit ->
scan(T, [{number_literal, {Row, Column}, [H]} | Scanned], {Row, Column + 1}, {in_number, Closer});
_ ->
@@ -291,6 +293,8 @@ char_type(C) when ((C >= $a) andalso (C =< $z)) orelse ((C >= $A) andalso (C =<
letter_underscore;
char_type(C) when ((C >= $0) andalso (C =< $9)) ->
digit;
+char_type($-) ->
+ hyphen_minus;
char_type(_C) ->
undefined.
2  tests/src/erlydtl_unittests.erl
View
@@ -177,6 +177,8 @@ tests() ->
{"if size comparison", [
{"If int greater than number literal",
<<"{% if var1 > 2 %}yay{% endif %}">>, [{var1, 3}], <<"yay">>},
+ {"If int greater than negative number literal",
+ <<"{% if var1 > -2 %}yay{% endif %}">>, [{var1, -1}], <<"yay">>},
{"If int greater than number literal (false)",
<<"{% if var1 > 2 %}yay{% endif %}">>, [{var1, 2}], <<"">>},
Please sign in to comment.
Something went wrong with that request. Please try again.