summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-09-01 23:52:16 +0900
committerYukihiro Matsumoto <[email protected]>2012-09-01 23:52:16 +0900
commite7661b978d77b1aa612bb1f833993616e8216a96 (patch)
tree5265752b15db6db17120331c6da48bf9e9886c48 /src
parentd1a453a89b76fd0f374ded382ebfc345e34b0180 (diff)
downloadmruby-e7661b978d77b1aa612bb1f833993616e8216a96.tar.gz
mruby-e7661b978d77b1aa612bb1f833993616e8216a96.zip
manage line number in yacc rules, not in lexer
Diffstat (limited to 'src')
-rw-r--r--src/parse.y16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/parse.y b/src/parse.y
index 3e0c670ea..79c7514e7 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -2916,7 +2916,7 @@ opt_terms : /* none */
;
opt_nl : /* none */
- | '\n'
+ | nl
;
rparen : opt_nl ')'
@@ -2926,14 +2926,20 @@ rbracket : opt_nl ']'
;
trailer : /* none */
- | '\n'
+ | nl
| ','
;
term : ';' {yyerrok;}
- | '\n'
+ | nl
;
+nl : '\n'
+ {
+ p->lineno++;
+ p->column = 0;
+ }
+
terms : term
| terms ';' {yyerrok;}
;
@@ -3515,14 +3521,14 @@ parser_yylex(parser_state *p)
skip(p, '\n');
/* fall through */
case '\n':
- p->lineno++;
- p->column = 0;
switch (p->lstate) {
case EXPR_BEG:
case EXPR_FNAME:
case EXPR_DOT:
case EXPR_CLASS:
case EXPR_VALUE:
+ p->lineno++;
+ p->column = 0;
goto retry;
default:
break;