summaryrefslogtreecommitdiff
path: root/perly.y
diff options
context:
space:
mode:
authorZefram <zefram@fysh.org>2010-10-15 13:11:54 +0100
committerFather Chrysostomos <sprout@cpan.org>2010-10-21 05:54:01 -0700
commite53d8f768a2bcb331fe11ed5282d228a938ce161 (patch)
tree7a753652885308a61615a5e1c4caa4b7a67ca4b3 /perly.y
parent9eb5c532bf567fdd066254fcaacf4a66722714c5 (diff)
downloadperl-e53d8f768a2bcb331fe11ed5282d228a938ce161.tar.gz
function to parse Perl code block
New API function parse_block() parses a code block, including surrounding braces. The block is a lexical scope, but not inherently a dynamic scope.
Diffstat (limited to 'perly.y')
-rw-r--r--perly.y13
1 files changed, 12 insertions, 1 deletions
diff --git a/perly.y b/perly.y
index 2b34f7d782..a70122d101 100644
--- a/perly.y
+++ b/perly.y
@@ -69,7 +69,7 @@
#endif
}
-%token <ival> GRAMPROG GRAMFULLSTMT GRAMSTMTSEQ
+%token <ival> GRAMPROG GRAMBLOCK GRAMFULLSTMT GRAMSTMTSEQ
%token <i_tkval> '{' '}' '[' ']' '-' '+' '$' '@' '%' '*' '&' ';'
@@ -143,6 +143,17 @@
/* Top-level choice of what kind of thing yyparse was called to parse */
grammar : GRAMPROG prog
{ $$ = $2; }
+ | GRAMBLOCK
+ {
+ parser->expect = XBLOCK;
+ }
+ block
+ {
+ PL_eval_root = $3;
+ $$ = 0;
+ yyunlex();
+ parser->yychar = YYEOF;
+ }
| GRAMFULLSTMT
{
parser->expect = XSTATE;