This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Distinguish C- and perly- literals - PERLY_BRACE_CLOSE
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index c9a6d9a..349ed4c 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -45,8 +45,9 @@
 
 %token <ival> GRAMPROG GRAMEXPR GRAMBLOCK GRAMBARESTMT GRAMFULLSTMT GRAMSTMTSEQ GRAMSUBSIGNATURE
 
-%token <ival> '}' '[' ']' '-' '+' '@' '%' '&' '=' '.'
+%token <ival> '[' ']' '-' '+' '@' '%' '&' '=' '.'
 %token <ival> PERLY_BRACE_OPEN
+%token <ival> PERLY_BRACE_CLOSE
 
 %token <opval> BAREWORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST
 %token <opval> FUNC0OP FUNC0SUB UNIOPSUB LSTOPSUB
@@ -202,7 +203,7 @@ grammar     :       GRAMPROG
        ;
 
 /* An ordinary block */
-block  :       PERLY_BRACE_OPEN remember stmtseq '}'
+block  :       PERLY_BRACE_OPEN remember stmtseq PERLY_BRACE_CLOSE
                        { if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
                              parser->copline = (line_t)$PERLY_BRACE_OPEN;
                          $$ = block_end($remember, $stmtseq);
@@ -222,7 +223,7 @@ remember:   /* NULL */      /* start a full lexical scope */
                          parser->parsed_sub = 0; }
        ;
 
-mblock :       PERLY_BRACE_OPEN mremember stmtseq '}'
+mblock :       PERLY_BRACE_OPEN mremember stmtseq PERLY_BRACE_CLOSE
                        { if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
                              parser->copline = (line_t)$PERLY_BRACE_OPEN;
                          $$ = block_end($mremember, $stmtseq);
@@ -458,7 +459,7 @@ barestmt:   PLUGSTMT
                              package_version($version);
                          }
                        }
-               stmtseq '}'
+               stmtseq PERLY_BRACE_CLOSE
                        {
                          /* a block is a loop that happens once */
                          $$ = newWHILEOP(0, 1, NULL,
@@ -857,7 +858,7 @@ optsubbody: subbody { $$ = $subbody; }
 
 
 /* Subroutine body (without signature) */
-subbody:       remember  PERLY_BRACE_OPEN stmtseq '}'
+subbody:       remember  PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
                        {
                          if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
                              parser->copline = (line_t)$PERLY_BRACE_OPEN;
@@ -872,7 +873,7 @@ optsigsubbody:      sigsubbody { $$ = $sigsubbody; }
        |       ';'        { $$ = NULL; }
 
 /* Subroutine body with optional signature */
-sigsubbody:    remember optsubsignature PERLY_BRACE_OPEN stmtseq '}'
+sigsubbody:    remember optsubsignature PERLY_BRACE_OPEN stmtseq PERLY_BRACE_CLOSE
                        {
                          if (parser->copline > (line_t)$PERLY_BRACE_OPEN)
                              parser->copline = (line_t)$PERLY_BRACE_OPEN;
@@ -957,7 +958,7 @@ method      :       METHOD
        ;
 
 /* Some kind of subscripted expression */
-subscripted:    gelem PERLY_BRACE_OPEN expr ';' '}'        /* *main::{something} */
+subscripted:    gelem PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE        /* *main::{something} */
                         /* In this and all the hash accessors, ';' is
                          * provided by the tokeniser */
                        { $$ = newBINOP(OP_GELEM, 0, $gelem, scalar($expr)); }
@@ -974,14 +975,14 @@ subscripted:    gelem PERLY_BRACE_OPEN expr ';' '}'        /* *main::{something}
                                        ref(newAVREF($array_reference),OP_RV2AV),
                                        scalar($expr));
                        }
-       |       scalar[hash] PERLY_BRACE_OPEN expr ';' '}'    /* $foo{bar();} */
+       |       scalar[hash] PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE    /* $foo{bar();} */
                        { $$ = newBINOP(OP_HELEM, 0, oopsHV($hash), jmaybe($expr));
                        }
-       |       term[hash_reference] ARROW PERLY_BRACE_OPEN expr ';' '}' /* somehref->{bar();} */
+       |       term[hash_reference] ARROW PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE /* somehref->{bar();} */
                        { $$ = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF($hash_reference),OP_RV2HV),
                                        jmaybe($expr)); }
-       |       subscripted[hash_reference] PERLY_BRACE_OPEN expr ';' '}' /* $foo->[bar]->{baz;} */
+       |       subscripted[hash_reference] PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE /* $foo->[bar]->{baz;} */
                        { $$ = newBINOP(OP_HELEM, 0,
                                        ref(newHVREF($hash_reference),OP_RV2HV),
                                        jmaybe($expr)); }
@@ -1127,9 +1128,9 @@ anonymous:        '[' expr ']'
                        { $$ = newANONLIST($expr); }
        |       '[' ']'
                        { $$ = newANONLIST(NULL);}
-       |       HASHBRACK expr ';' '}'  %prec '(' /* { foo => "Bar" } */
+       |       HASHBRACK expr ';' PERLY_BRACE_CLOSE    %prec '(' /* { foo => "Bar" } */
                        { $$ = newANONHASH($expr); }
-       |       HASHBRACK ';' '}'       %prec '(' /* { } (';' by tokener) */
+       |       HASHBRACK ';' PERLY_BRACE_CLOSE %prec '(' /* { } (';' by tokener) */
                        { $$ = newANONHASH(NULL); }
        |       ANONSUB     startanonsub proto subattrlist subbody    %prec '('
                        { SvREFCNT_inc_simple_void(PL_compcv);
@@ -1198,7 +1199,7 @@ term[product]     :       termbinop
                              $$->op_private |=
                                  $kvslice->op_private & OPpSLICEWARNING;
                        }
-       |       sliceme PERLY_BRACE_OPEN expr ';' '}'                 /* @hash{@keys} */
+       |       sliceme PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE                 /* @hash{@keys} */
                        { $$ = op_prepend_elem(OP_HSLICE,
                                newOP(OP_PUSHMARK, 0),
                                    newLISTOP(OP_HSLICE, 0,
@@ -1208,7 +1209,7 @@ term[product]     :       termbinop
                              $$->op_private |=
                                  $sliceme->op_private & OPpSLICEWARNING;
                        }
-       |       kvslice PERLY_BRACE_OPEN expr ';' '}'                 /* %hash{@keys} */
+       |       kvslice PERLY_BRACE_OPEN expr ';' PERLY_BRACE_CLOSE                 /* %hash{@keys} */
                        { $$ = op_prepend_elem(OP_KVHSLICE,
                                newOP(OP_PUSHMARK, 0),
                                    newLISTOP(OP_KVHSLICE, 0,