diff options
| author | fleuria <[email protected]> | 2013-10-30 00:03:04 +0800 |
|---|---|---|
| committer | fleuria <[email protected]> | 2013-10-30 10:34:28 +0800 |
| commit | 3a4c8e2d9fac288bfe6948c15fc3dc14449b17cd (patch) | |
| tree | bf7092278478d0e053431b300b57626e4f59884a | |
| parent | a230a88e8994f7be0256e552d5ea186adec7222f (diff) | |
| download | mruby-3a4c8e2d9fac288bfe6948c15fc3dc14449b17cd.tar.gz mruby-3a4c8e2d9fac288bfe6948c15fc3dc14449b17cd.zip | |
fix #1550
emit a "\n" as the first token for parser instead of taking the
first character from the next file for lexer, to prevent mruby
"concatenate" two keywords between files
it should be regarded as a work around, for it can not resolve
this case:
$ cat a.rb
"
$ cat b.rb
b"
$ bin/mrbc -o- -v a.rb b.rb
mruby - Embeddable Ruby Copyright (c) 2010-2013 mruby
developers
NODE_SCOPE:
NODE_BEGIN:
NODE_STR "
b " len 4
irep 0 nregs=2 nlocals=1 pools=1 syms=0
000 OP_STRING R1 "\n\nb "
001 OP_STOP
thanks @bovi 's idea
| -rw-r--r-- | src/parse.y | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/parse.y b/src/parse.y index 7cac9b0c5..3ffc683f9 100644 --- a/src/parse.y +++ b/src/parse.y @@ -37,6 +37,7 @@ static void yyerror(parser_state *p, const char *s); static void yywarn(parser_state *p, const char *s); static void yywarning(parser_state *p, const char *s); static void backref_error(parser_state *p, node *n); +static void tokadd(parser_state *p, int c); #ifndef isascii #define isascii(c) (((c) & ~0x7f) == 0) @@ -3338,6 +3339,7 @@ nextc(parser_state *p) if (cxt->partial_hook(p) < 0) return -1; p->cxt = NULL; + tokadd(p, '\n'); c = nextc(p); p->cxt = cxt; return c; |
