diff options
author | Zefram <zefram@fysh.org> | 2010-10-04 10:26:42 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2010-10-04 10:26:42 +0200 |
commit | 07ffcb738e9467df21e3d33604cf09c125e7ff52 (patch) | |
tree | 4d9f19d1b037c0559de25681d55a3a2f7569e2ce /perly.y | |
parent | ad97526782cdd5392f99d55127e22a7eb5ea9851 (diff) | |
download | perl-07ffcb738e9467df21e3d33604cf09c125e7ff52.tar.gz |
[PATCH] function to parse Perl statement sequence
New API function parse_stmtseq() parses a sequence of statements, up to
closing brace or EOF.
Diffstat (limited to 'perly.y')
-rw-r--r-- | perly.y | 29 |
1 files changed, 27 insertions, 2 deletions
@@ -69,7 +69,7 @@ #endif } -%token <ival> GRAMPROG GRAMFULLSTMT +%token <ival> GRAMPROG GRAMFULLSTMT GRAMSTMTSEQ %token <i_tkval> '{' '}' '[' ']' '-' '+' '$' '@' '%' '*' '&' ';' @@ -89,7 +89,7 @@ %type <i_tkval> lpar_or_qw -%type <ival> grammar prog progstart remember mremember +%type <ival> grammar closebrace_or_eof prog progstart remember mremember %type <ival> startsub startanonsub startformsub /* FIXME for MAD - are these two ival? */ %type <ival> mydefsv mintro @@ -150,6 +150,31 @@ grammar : GRAMPROG prog yyunlex(); parser->yychar = YYEOF; } + | GRAMSTMTSEQ + { + parser->expect = XSTATE; + } + lineseq closebrace_or_eof + { + PL_eval_root = $3; + $$ = 0; + } + ; + +closebrace_or_eof: '}' + { + assert(parser->yychar == YYEMPTY); + assert(parser->bufptr != SvPVX(parser->linestr)); + assert(parser->bufptr[-1] == '}'); + parser->bufptr--; + parser->lex_brackstack[parser->lex_brackets++] = + XSTATE; + parser->expect = XSTATE; + parser->yychar = YYEOF; + $$ = 0; + } + | /* NULL */ + { $$ = 0; } ; /* The whole program */ |