%token <ival> PERLY_BRACKET_OPEN
%token <ival> PERLY_BRACKET_CLOSE
%token <ival> PERLY_COMMA
+%token <ival> PERLY_DOLLAR
%token <ival> PERLY_DOT
%token <ival> PERLY_EQUAL_SIGN
%token <ival> PERLY_MINUS
%token <ival> PERLY_PERCENT_SIGN
%token <ival> PERLY_PLUS
%token <ival> PERLY_SEMICOLON
+%token <ival> PERLY_SLASH
%token <ival> PERLY_SNAIL
%token <ival> PERLY_STAR
%token <ival> FORMAT SUB SIGSUB ANONSUB ANON_SIGSUB PACKAGE USE
%token <ival> WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
%token <ival> GIVEN WHEN DEFAULT
+%token <ival> TRY CATCH
%token <ival> LOOPEX DOTDOT YADAYADA
%token <ival> FUNC0 FUNC1 FUNC UNIOP LSTOP
%token <ival> MULOP ADDOP
%nonassoc <ival> PREC_LOW
%nonassoc LOOPEX
-%left <ival> OROP DOROP
+%left <ival> OROP
%left <ival> ANDOP
%right <ival> NOTOP
%nonassoc LSTOP LSTOPSUB
}
;
-remember: /* NULL */ /* start a full lexical scope */
+remember: %empty /* start a full lexical scope */
{ $$ = block_start(TRUE);
parser->parsed_sub = 0; }
;
}
;
-mremember: /* NULL */ /* start a partial lexical scope */
+mremember: %empty /* start a partial lexical scope */
{ $$ = block_start(FALSE);
parser->parsed_sub = 0; }
;
/* A sequence of statements in the program */
-stmtseq : /* NULL */
+stmtseq : %empty
{ $$ = NULL; }
| stmtseq[list] fullstmt
{ $$ = op_append_list(OP_LINESEQ, $list, $fullstmt);
;
/* A sequence of format lines */
-formstmtseq: /* NULL */
+formstmtseq: %empty
{ $$ = NULL; }
| formstmtseq[list] formline
{ $$ = op_append_list(OP_LINESEQ, $list, $formline);
newFOROP(0, NULL, $mexpr, $mblock, $cont));
parser->copline = (line_t)$FOR;
}
+ | TRY mblock[try] CATCH PERLY_PAREN_OPEN
+ { parser->in_my = 1; }
+ remember scalar
+ { parser->in_my = 0; intro_my(); }
+ PERLY_PAREN_CLOSE mblock[catch]
+ {
+ $$ = newTRYCATCHOP(0,
+ $try, $scalar, block_end($remember, op_scope($catch)));
+ }
| block cont
{
/* a block is a loop that happens once */
}
;
-formarg : /* NULL */
+formarg : %empty
{ $$ = NULL; }
| FORMLBRACK stmtseq FORMRBRACK
{ $$ = op_unscope($stmtseq); }
;
/* else and elsif blocks */
-else : /* NULL */
+else : %empty
{ $$ = NULL; }
| ELSE mblock
{
;
/* Continue blocks */
-cont : /* NULL */
+cont : %empty
{ $$ = NULL; }
| CONTINUE block
{ $$ = op_scope($block); }
;
/* determine whether there are any new my declarations */
-mintro : /* NULL */
+mintro : %empty
{ $$ = (PL_min_intro_pending &&
PL_max_intro_pending >= PL_min_intro_pending);
intro_my(); }
/* Normal expression */
-nexpr : /* NULL */
+nexpr : %empty
{ $$ = NULL; }
| sideff
;
/* Boolean expression */
-texpr : /* NULL means true */
+texpr : %empty /* NULL means true */
{ YYSTYPE tmplval;
(void)scan_num("1", &tmplval);
$$ = tmplval.opval; }
;
formname: BAREWORD { $$ = $BAREWORD; }
- | /* NULL */ { $$ = NULL; }
+ | %empty { $$ = NULL; }
;
-startsub: /* NULL */ /* start a regular subroutine scope */
+startsub: %empty /* start a regular subroutine scope */
{ $$ = start_subparse(FALSE, 0);
SAVEFREESV(PL_compcv); }
;
-startanonsub: /* NULL */ /* start an anonymous subroutine scope */
+startanonsub: %empty /* start an anonymous subroutine scope */
{ $$ = start_subparse(FALSE, CVf_ANON);
SAVEFREESV(PL_compcv); }
;
-startformsub: /* NULL */ /* start a format subroutine scope */
+startformsub: %empty /* start a format subroutine scope */
{ $$ = start_subparse(TRUE, 0);
SAVEFREESV(PL_compcv); }
;
;
/* Subroutine prototype */
-proto : /* NULL */
+proto : %empty
{ $$ = NULL; }
| THING
;
/* Optional list of subroutine attributes */
-subattrlist: /* NULL */
+subattrlist: %empty
{ $$ = NULL; }
| COLONATTR THING
{ $$ = $THING; }
*/
/* the '' or 'foo' part of a '$' or '@foo' etc signature variable */
-sigvarname: /* NULL */
+sigvarname: %empty
{ parser->in_my = 0; $$ = NULL; }
| PRIVATEREF
{ parser->in_my = 0; $$ = $PRIVATEREF; }
;
/* default part of sub signature scalar element: i.e. '= default_expr' */
-sigdefault: /* NULL */
+sigdefault: %empty
{ $$ = NULL; }
| ASSIGNOP
{ $$ = newOP(OP_NULL, 0); }
/* subroutine signature scalar element: e.g. '$x', '$=', '$x = $default' */
sigscalarelem:
- '$' sigvarname sigdefault
+ PERLY_DOLLAR sigvarname sigdefault
{
OP *var = $sigvarname;
OP *defexpr = $sigdefault;
;
/* () or (....) */
-siglistornull: /* NULL */
+siglistornull: %empty
{ $$ = NULL; }
| siglist
{ $$ = $siglist; }
/* optional subroutine signature */
-optsubsignature: /* NULL */
+optsubsignature: %empty
{ $$ = NULL; }
| subsignature
{ $$ = $subsignature; }
{ $$ = newLOGOP(OP_AND, 0, $lhs, $rhs); }
| expr[lhs] OROP[operator] expr[rhs]
{ $$ = newLOGOP($operator, 0, $lhs, $rhs); }
- | expr[lhs] DOROP expr[rhs]
- { $$ = newLOGOP(OP_DOR, 0, $lhs, $rhs); }
| listexpr %prec PREC_LOW
;
{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
op_append_elem(OP_LIST, $optlistexpr, scalar($subname)));
}
- | term[operand] ARROW '$' PERLY_STAR
+ | term[operand] ARROW PERLY_DOLLAR PERLY_STAR
{ $$ = newSVREF($operand); }
| term[operand] ARROW PERLY_SNAIL PERLY_STAR
{ $$ = newAVREF($operand); }
;
/* Basic list expressions */
-optlistexpr: /* NULL */ %prec PREC_LOW
+optlistexpr: %empty %prec PREC_LOW
{ $$ = NULL; }
| listexpr %prec PREC_LOW
{ $$ = $listexpr; }
;
-optexpr: /* NULL */
+optexpr: %empty
{ $$ = NULL; }
| expr
{ $$ = $expr; }
;
-optrepl: /* NULL */
+optrepl: %empty
{ $$ = NULL; }
- | '/' expr
+ | PERLY_SLASH expr
{ $$ = $expr; }
;
{ $$ = newCVREF($PERLY_AMPERSAND,$indirob); }
;
-scalar : '$' indirob
+scalar : PERLY_DOLLAR indirob
{ $$ = newSVREF($indirob); }
;