Skip to content

Commit

Permalink
parse.y: separate numeric literal
Browse files Browse the repository at this point in the history
* parse.y (parser_yylex): separate numeric literal from succeeding
  token, and treat 'e' as floating point number only if followed by
  exponent part.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jul 26, 2013
1 parent 2d9a4af commit 41f864f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Fri Jul 26 23:05:27 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>

* parse.y (parser_yylex): separate numeric literal from succeeding
token, and treat 'e' as floating point number only if followed by
exponent part.

Fri Jul 26 22:14:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>

* vm_exec.h (CHECK_VM_STACK_OVERFLOW_FOR_INSN): surround with
Expand Down
14 changes: 9 additions & 5 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -7542,14 +7542,18 @@ parser_yylex(struct parser_params *parser)
if (seen_e) {
goto decode_num;
}
tokadd(c);
seen_e++;
is_float++;
nondigit = c;
c = nextc();
if (c != '-' && c != '+') continue;
if (c != '-' && c != '+' && !ISDIGIT(c)) {
pushback(c);
nondigit = 0;
goto decode_num;
}
tokadd(nondigit);
seen_e++;
is_float++;
tokadd(c);
nondigit = c;
nondigit = (c == '-' || c == '+') ? c : 0;
break;

case '_': /* `_' in number just ignored */
Expand Down
7 changes: 7 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,13 @@ def test_constant_reassignment_toplevel
assert_constant_reassignment_toplevel("11", "+", %w[53], already)
end

def test_integer_suffix
["1if true", "begin 1end"].each do |src|
assert_valid_syntax(src)
assert_equal(1, eval(src), src)
end
end

private

def not_label(x) @result = x; @not_label ||= nil end
Expand Down

0 comments on commit 41f864f

Please sign in to comment.