summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--parse.y14
-rw-r--r--test/ruby/test_syntax.rb7
3 files changed, 22 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 6b84b766a48..f7354133123 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/parse.y b/parse.y
index fa5609a6490..d4e73e00723 100644
--- a/parse.y
+++ b/parse.y
@@ -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 */
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 34bd1e0191f..9daa0e4d495 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -363,6 +363,13 @@ eom
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