This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Un-special case something
[perl5.git] / perly.y
diff --git a/perly.y b/perly.y
index f28124d..7d57dea 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -143,7 +143,7 @@ grammar     :       GRAMPROG
                          PL_eval_root = $3;
                          $$ = 0;
                          yyunlex();
-                         parser->yychar = YYEOF;
+                         parser->yychar = yytoken = YYEOF;
                        }
        |       GRAMBARESTMT
                        {
@@ -155,7 +155,7 @@ grammar     :       GRAMPROG
                          PL_eval_root = $3;
                          $$ = 0;
                          yyunlex();
-                         parser->yychar = YYEOF;
+                         parser->yychar = yytoken = YYEOF;
                        }
        |       GRAMFULLSTMT
                        {
@@ -167,7 +167,7 @@ grammar     :       GRAMPROG
                          PL_eval_root = $3;
                          $$ = 0;
                          yyunlex();
-                         parser->yychar = YYEOF;
+                         parser->yychar = yytoken = YYEOF;
                        }
        |       GRAMSTMTSEQ
                        {
@@ -215,7 +215,7 @@ mremember:  /* NULL */      /* start a partial lexical scope */
 
 /* A sequence of statements in the program */
 stmtseq        :       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       stmtseq fullstmt
                        {   $$ = op_append_list(OP_LINESEQ, $1, $2);
                            PL_pad_reset_pending = TRUE;
@@ -226,7 +226,7 @@ stmtseq     :       /* NULL */
 
 /* A sequence of format lines */
 formstmtseq:   /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       formstmtseq formline
                        {   $$ = op_append_list(OP_LINESEQ, $1, $2);
                            PL_pad_reset_pending = TRUE;
@@ -261,7 +261,7 @@ barestmt:   PLUGSTMT
                        {
                          CV *fmtcv = PL_compcv;
                          newFORM($2, $3, $4);
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                          if (CvOUTSIDE(fmtcv) && !CvEVAL(CvOUTSIDE(fmtcv))) {
                              pad_add_weakref(fmtcv);
                          }
@@ -296,7 +296,7 @@ barestmt:   PLUGSTMT
                              ? newATTRSUB($3, $2, $5, $6, $7)
                              : newMYSUB($3, $2, $5, $6, $7)
                          ;
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                          intro_my();
                          parser->parsed_sub = 1;
                        }
@@ -335,7 +335,7 @@ barestmt:   PLUGSTMT
                              ? newATTRSUB($3, $2, NULL, $7, body)
                              : newMYSUB($3, $2, NULL, $7, body)
                          ;
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                          intro_my();
                          parser->parsed_sub = 1;
                        }
@@ -344,7 +344,7 @@ barestmt:   PLUGSTMT
                          package($3);
                          if ($2)
                              package_version($2);
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                        }
        |       USE startsub
                        { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
@@ -353,7 +353,7 @@ barestmt:   PLUGSTMT
                          SvREFCNT_inc_simple_void(PL_compcv);
                          utilize($1, $2, $4, $5, $6);
                          parser->parsed_sub = 1;
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                        }
        |       IF '(' remember mexpr ')' mblock else
                        {
@@ -379,14 +379,14 @@ barestmt: PLUGSTMT
        |       WHILE '(' remember texpr ')' mintro mblock cont
                        {
                          $$ = block_end($3,
-                                 newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
+                                 newWHILEOP(0, 1, NULL,
                                      $4, $7, $8, $6));
                          parser->copline = (line_t)$1;
                        }
        |       UNTIL '(' remember iexpr ')' mintro mblock cont
                        {
                          $$ = block_end($3,
-                                 newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
+                                 newWHILEOP(0, 1, NULL,
                                      $4, $7, $8, $6));
                          parser->copline = (line_t)$1;
                        }
@@ -398,7 +398,7 @@ barestmt:   PLUGSTMT
                mblock
                        {
                          OP *initop = $4;
-                         OP *forop = newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
+                         OP *forop = newWHILEOP(0, 1, NULL,
                                      scalar($7), $13, $11, $10);
                          if (initop) {
                              forop = op_prepend_elem(OP_LINESEQ, initop,
@@ -447,14 +447,14 @@ barestmt: PLUGSTMT
        |       FOR '(' remember mexpr ')' mblock cont
                        {
                          $$ = block_end($3,
-                                 newFOROP(0, (OP*)NULL, $4, $6, $7));
+                                 newFOROP(0, NULL, $4, $6, $7));
                          parser->copline = (line_t)$1;
                        }
        |       block cont
                        {
                          /* a block is a loop that happens once */
-                         $$ = newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
-                                 (OP*)NULL, $1, $2, 0);
+                         $$ = newWHILEOP(0, 1, NULL,
+                                 NULL, $1, $2, 0);
                        }
        |       PACKAGE BAREWORD BAREWORD '{' remember
                        {
@@ -466,8 +466,8 @@ barestmt:   PLUGSTMT
                stmtseq '}'
                        {
                          /* a block is a loop that happens once */
-                         $$ = newWHILEOP(0, 1, (LOOP*)(OP*)NULL,
-                                 (OP*)NULL, block_end($5, $7), (OP*)NULL, 0);
+                         $$ = newWHILEOP(0, 1, NULL,
+                                 NULL, block_end($5, $7), NULL, 0);
                          if (parser->copline > (line_t)$4)
                              parser->copline = (line_t)$4;
                        }
@@ -477,7 +477,7 @@ barestmt:   PLUGSTMT
                        }
        |       ';'
                        {
-                         $$ = (OP*)NULL;
+                         $$ = NULL;
                          parser->copline = NOLINE;
                        }
        ;
@@ -508,7 +508,7 @@ formarg     :       /* NULL */
 
 /* An expression which may have a side-effect */
 sideff :       error
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       expr
                        { $$ = $1; }
        |       expr IF expr
@@ -520,7 +520,7 @@ sideff      :       error
        |       expr UNTIL iexpr
                        { $$ = newLOOPOP(OPf_PARENS, 1, $3, $1); }
        |       expr FOR expr
-                       { $$ = newFOROP(0, (OP*)NULL, $3, $1, (OP*)NULL);
+                       { $$ = newFOROP(0, NULL, $3, $1, NULL);
                          parser->copline = (line_t)$2; }
        |       expr WHEN expr
                        { $$ = newWHENOP($3, op_scope($1)); }
@@ -528,7 +528,7 @@ sideff      :       error
 
 /* else and elsif blocks */
 else   :       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       ELSE mblock
                        {
                          ($2)->op_flags |= OPf_PARENS;
@@ -545,7 +545,7 @@ else        :       /* NULL */
 
 /* Continue blocks */
 cont   :       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       CONTINUE block
                        { $$ = op_scope($2); }
        ;
@@ -558,7 +558,7 @@ mintro      :       /* NULL */
 
 /* Normal expression */
 nexpr  :       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       sideff
        ;
 
@@ -585,7 +585,7 @@ mnexpr      :       nexpr
        ;
 
 formname:      BAREWORD        { $$ = $1; }
-       |       /* NULL */      { $$ = (OP*)NULL; }
+       |       /* NULL */      { $$ = NULL; }
        ;
 
 startsub:      /* NULL */      /* start a regular subroutine scope */
@@ -611,24 +611,24 @@ subname   :       BAREWORD
 
 /* Subroutine prototype */
 proto  :       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       THING
        ;
 
 /* Optional list of subroutine attributes */
 subattrlist:   /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       COLONATTR THING
                        { $$ = $2; }
        |       COLONATTR
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        ;
 
 /* List of attributes for a "my" variable declaration */
 myattrlist:    COLONATTR THING
                        { $$ = $2; }
        |       COLONATTR
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        ;
 
 
@@ -638,13 +638,10 @@ myattrlist:       COLONATTR THING
  */
 
 /* the '' or 'foo' part of a '$' or '@foo' etc signature variable  */
-sigvarname:   /* NULL */
-                       { $$ = (OP*)NULL; }
+sigvarname:     /* NULL */
+                       { parser->in_my = 0; $$ = NULL; }
         |       PRIVATEREF
-                        {
-                            $$ = $1;
-                            PL_parser->in_my = 0;
-                        }
+                        { parser->in_my = 0; $$ = $1; }
        ;
 
 sigslurpsigil:
@@ -656,53 +653,25 @@ sigslurpsigil:
 /* @, %, @foo, %foo */
 sigslurpelem: sigslurpsigil sigvarname sigdefault/* def only to catch errors */ 
                         {
-                            I32 sigil = $1;
-                            OP *var   = $2;
+                            I32 sigil   = $1;
+                            OP *var     = $2;
                             OP *defexpr = $3;
-                            int type = (sigil == '@' ? OP_PADAV : OP_PADHV);
 
-                            if (PL_parser->sig_slurpy)
+                            if (parser->sig_slurpy)
                                 yyerror("Multiple slurpy parameters not allowed");
-                            PL_parser->sig_slurpy = sigil;
+                            parser->sig_slurpy = (char)sigil;
 
                             if (defexpr)
-                                yyerror("a slurpy parameter may not have "
+                                yyerror("A slurpy parameter may not have "
                                         "a default value");
 
-                            if (var) {
-                                OP *slice;
-
-                                var->op_type    = type;
-                                var->op_ppaddr  = PL_ppaddr[type];
-                                var->op_flags   = (OPf_WANT_LIST | OPf_MOD);
-                                var->op_private = OPpLVAL_INTRO;
-
-                                slice = PL_parser->sig_elems
-                                    ? op_prepend_elem(OP_ASLICE,
-                                        newOP(OP_PUSHMARK, 0),
-                                        newLISTOP(OP_ASLICE, 0,
-                                            list(newRANGE(0,
-                                                newSVOP(OP_CONST, 0,
-                                                    newSViv(PL_parser->sig_elems)),
-                                                newUNOP(OP_AV2ARYLEN, 0,
-                                                    ref(newUNOP(OP_RV2AV, 0,
-                                                            newGVOP(OP_GV, 0, PL_defgv)),
-                                                        OP_AV2ARYLEN)))),
-                                            ref(newUNOP(OP_RV2AV, 0,
-                                                    newGVOP(OP_GV, 0, PL_defgv)),
-                                                OP_ASLICE)))
-                                    : newUNOP(OP_RV2AV, 0, newGVOP(OP_GV, 0, PL_defgv));
-                                $$ = newSTATEOP(0, NULL,
-                                       newASSIGNOP(OPf_STACKED, var, 0, slice));
-                            }
-                            else
-                                $$ = (OP*)NULL;
+                            $$ = var ? newSTATEOP(0, NULL, var) : NULL;
                         }
        ;
 
 /* default part of sub signature scalar element: i.e. '= default_expr' */
 sigdefault:    /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
         |       ASSIGNOP
                         { $$ = newOP(OP_NULL, 0); }
         |       ASSIGNOP term
@@ -715,84 +684,71 @@ sigscalarelem:
                         {
                             OP *var     = $2;
                             OP *defexpr = $3;
-                            OP *argn    = NULL;
-                            OP *expr    = NULL;
 
-                            if (PL_parser->sig_slurpy)
+                            if (parser->sig_slurpy)
                                 yyerror("Slurpy parameter not last");
 
-                            PL_parser->sig_elems++;
-
-                            if (var) {
-                                var->op_type    = OP_PADSV;
-                                var->op_ppaddr  = PL_ppaddr[OP_PADSV];
-                                var->op_flags   = (OPf_WANT_SCALAR | OPf_MOD);
-                                var->op_private = OPpLVAL_INTRO;
-                            }
-
-                            /* $_[N] */
-                            argn = newBINOP(OP_AELEM, 0,
-                                ref(newUNOP(OP_RV2AV, 0,
-                                        newGVOP(OP_GV, 0, PL_defgv)),
-                                    OP_RV2AV),
-                                newSVOP(OP_CONST, 0,
-                                    newSViv(PL_parser->sig_elems - 1)));
+                            parser->sig_elems++;
 
                             if (defexpr) {
-                                PL_parser->sig_optelems++;
-                                /* is it '$var=undef', '$=' ? */
-                                if (    (   defexpr->op_type == OP_NULL
-                                         || defexpr->op_type == OP_UNDEF)
+                                parser->sig_optelems++;
+
+                                if (   defexpr->op_type == OP_NULL
                                     && !(defexpr->op_flags & OPf_KIDS))
                                 {
-                                    if (var) {
-                                        /* '$=' is legal, '$var=' isn't */
-                                        if (defexpr->op_type == OP_NULL)
-                                            yyerror("Optional parameter "
-                                                "lacks default expression");
-                                        else
-                                            expr = argn;
-                                    }
+                                    /* handle '$=' special case */
+                                    if (var)
+                                        yyerror("Optional parameter "
+                                                    "lacks default expression");
                                     op_free(defexpr);
                                 }
-                                else {
-                                    /* @_ >= N */
-                                    OP *ge_op = 
-                                        newBINOP(OP_GE, 0,
-                                        scalar(newUNOP(OP_RV2AV, 0,
-                                                newGVOP(OP_GV, 0, PL_defgv))),
-                                        newSVOP(OP_CONST, 0,
-                                            newSViv(PL_parser->sig_elems)));
-
-                                    expr = var
-                                        ? newCONDOP(0, ge_op, argn, defexpr)
-                                        : newLOGOP(OP_OR, 0, ge_op, defexpr);
+                                else { 
+                                    /* a normal '=default' expression */ 
+                                    OP *defop = (OP*)alloc_LOGOP(OP_ARGDEFELEM,
+                                                        defexpr,
+                                                        LINKLIST(defexpr));
+                                    /* re-purpose op_targ to hold @_ index */
+                                    defop->op_targ =
+                                        (PADOFFSET)(parser->sig_elems - 1);
+
+                                    if (var) {
+                                        var->op_flags |= OPf_STACKED;
+                                        (void)op_sibling_splice(var,
+                                                        NULL, 0, defop);
+                                        scalar(defop);
+                                    }
+                                    else
+                                        var = newUNOP(OP_NULL, 0, defop);
+
+                                    LINKLIST(var);
+                                    /* NB: normally the first child of a
+                                     * logop is executed before the logop,
+                                     * and it pushes a boolean result
+                                     * ready for the logop. For ARGDEFELEM,
+                                     * the op itself does the boolean
+                                     * calculation, so set the first op to
+                                     * it instead.
+                                     */
+                                    var->op_next = defop;
+                                    defexpr->op_next = var;
                                 }
                             }
                             else {
-                                if (PL_parser->sig_optelems)
+                                if (parser->sig_optelems)
                                     yyerror("Mandatory parameter "
                                             "follows optional parameter");
-                                expr = argn;
                             }
 
-                            if (var)
-                                expr = newASSIGNOP(OPf_STACKED, var, 0, expr);
-                            if (expr)
-                                $$ = op_prepend_elem(OP_LINESEQ,
-                                        newSTATEOP(0, NULL, NULL),
-                                        expr);
-                            else
-                                $$ = (OP*)NULL;
+                            $$ = var ? newSTATEOP(0, NULL, var) : NULL;
                         }
        ;
 
 
 /* subroutine signature element: e.g. '$x = $default' or '%h' */
 sigelem:        sigscalarelem
-                        { parser->expect = XSIGVAR; $$ = $1; }
+                        { parser->in_my = KEY_sigvar; $$ = $1; }
         |       sigslurpelem
-                        { parser->expect = XSIGVAR; $$ = $1; }
+                        { parser->in_my = KEY_sigvar; $$ = $1; }
        ;
 
 /* list of subroutine signature elements */
@@ -809,7 +765,7 @@ siglist:
 
 /* () or (....) */
 siglistornull:         /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       siglist
                        { $$ = $1; }
 
@@ -817,75 +773,47 @@ siglistornull:            /* NULL */
 subsignature:  '('
                         {
                             ENTER;
-                            SAVEINT(PL_parser->sig_elems);
-                            SAVEINT(PL_parser->sig_optelems);
-                            SAVEI8(PL_parser->sig_slurpy);
-                            PL_parser->sig_elems    = 0;
-                            PL_parser->sig_optelems = 0;
-                            PL_parser->sig_slurpy   = 0;
-                            parser->expect = XSIGVAR;
+                            SAVEIV(parser->sig_elems);
+                            SAVEIV(parser->sig_optelems);
+                            SAVEI8(parser->sig_slurpy);
+                            parser->sig_elems    = 0;
+                            parser->sig_optelems = 0;
+                            parser->sig_slurpy   = 0;
+                            parser->in_my        = KEY_sigvar;
                         }
                 siglistornull
                 ')'
                        {
-                            OP *sigops = $3;
-                            int min_arity =
-                                PL_parser->sig_elems - PL_parser->sig_optelems;
+                            OP            *sigops = $3;
+                            UNOP_AUX_item *aux;
+                            OP            *check;
 
-                            assert(FEATURE_SIGNATURES_IS_ENABLED);
+                            if (!parser->error_count) {
+                                assert(FEATURE_SIGNATURES_IS_ENABLED);
+                            }
 
                             /* We shouldn't get here otherwise */
                             Perl_ck_warner_d(aTHX_
                                 packWARN(WARN_EXPERIMENTAL__SIGNATURES),
                                 "The signatures feature is experimental");
 
-                            /* handle odd/even for %foo */
-                            if (PL_parser->sig_slurpy == '%') {
-                                OP *chkop =
-                                    newLOGOP(
-                                        (PL_parser->sig_elems & 1)
-                                                ? OP_OR : OP_AND,
-                                        0,
-                                        newBINOP(OP_BIT_AND, 0,
-                                            scalar(newUNOP(OP_RV2AV, 0,
-                                                newGVOP(OP_GV, 0, PL_defgv))),
-                                            newSVOP(OP_CONST, 0, newSViv(1))),
-                                        op_convert_list(OP_DIE, 0,
-                                            op_convert_list(OP_SPRINTF, 0,
-                                                op_append_list(OP_LIST,
-                                                    newSVOP(OP_CONST, 0,
-                                                        newSVpvs("Odd name/value argument for subroutine at %s line %d.\n")),
-                                                    newSLICEOP(0,
-                                                        op_append_list(OP_LIST,
-                                                            newSVOP(OP_CONST, 0, newSViv(1)),
-                                                            newSVOP(OP_CONST, 0, newSViv(2))),
-                                                        newOP(OP_CALLER, 0))))));
-                                if (PL_parser->sig_optelems)
-                                    chkop = newLOGOP(OP_AND, 0,
-                                                newBINOP(OP_GT, 0,
-                                                    scalar(newUNOP(OP_RV2AV, 0,
-                                                        newGVOP(OP_GV, 0, PL_defgv))),
-                                                    newSVOP(OP_CONST, 0,
-                                                    newSViv(PL_parser->sig_elems))),
-                                                chkop);
-                                sigops = op_prepend_elem(OP_LINESEQ,
-                                            chkop, sigops);
-
-                            }
-                            if (min_arity)
-                                sigops = op_prepend_elem(OP_LINESEQ,
-                                            Perl_check_arity(aTHX_ min_arity,
-                                                FALSE),
-                                            sigops);
-                            if (!PL_parser->sig_slurpy)
-                                sigops = op_prepend_elem(OP_LINESEQ,
-                                            Perl_check_arity(aTHX_
-                                                PL_parser->sig_elems, TRUE),
-                                            sigops);
-
-                            $$ = op_append_elem(OP_LINESEQ, sigops,
-                                newSTATEOP(0, NULL, NULL));
-
+                            aux = (UNOP_AUX_item*)PerlMemShared_malloc(
+                                sizeof(UNOP_AUX_item) * 3);
+                            aux[0].iv = parser->sig_elems;
+                            aux[1].iv = parser->sig_optelems;
+                            aux[2].iv = parser->sig_slurpy;
+                            check = newUNOP_AUX(OP_ARGCHECK, 0, NULL, aux);
+                            sigops = op_prepend_elem(OP_LINESEQ, check, sigops);
+                            sigops = op_prepend_elem(OP_LINESEQ,
+                                                newSTATEOP(0, NULL, NULL),
+                                                sigops);
+                            /* a nextstate at the end handles context
+                             * correctly for an empty sub body */
+                            $$ = op_append_elem(OP_LINESEQ,
+                                                sigops,
+                                                newSTATEOP(0, NULL, NULL));
+
+                            parser->in_my = 0;
                             parser->expect = XATTRBLOCK;
                             LEAVE;
                        }
@@ -895,7 +823,7 @@ subsignature:       '('
 
 /* Optional subroutine body, for named subroutine declaration */
 optsubbody:    block
-       |       ';'     { $$ = (OP*)NULL; }
+       |       ';'     { $$ = NULL; }
        ;
 
 /* Ordinary expressions; logical combinations */
@@ -957,7 +885,7 @@ listop      :       LSTOP indirob listexpr /* map {...} @args or print $fh @args */
                        { $$ = op_convert_list($1, 0, $3); }
        |       LSTOPSUB startanonsub block /* sub f(&@);   f { foo } ... */
                        { SvREFCNT_inc_simple_void(PL_compcv);
-                         $<opval>$ = newANONATTRSUB($2, 0, (OP*)NULL, $3); }
+                         $<opval>$ = newANONATTRSUB($2, 0, NULL, $3); }
                    optlistexpr         %prec LSTOP  /* ... @bar */
                        { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
                                 op_append_elem(OP_LIST,
@@ -1019,7 +947,7 @@ subscripted:    gelem '{' expr ';' '}'        /* *main::{something} */
        |       QWLIST '[' expr ']'            /* list literal slice */
                        { $$ = newSLICEOP(0, $3, $1); }
        |       '(' ')' '[' expr ']'                 /* empty list slice! */
-                       { $$ = newSLICEOP(0, $4, (OP*)NULL); }
+                       { $$ = newSLICEOP(0, $4, NULL); }
     ;
 
 /* Binary operators between terms */
@@ -1096,11 +1024,11 @@ termunop : '-' term %prec UMINUS                       /* -$x */
 anonymous:     '[' expr ']'
                        { $$ = newANONLIST($2); }
        |       '[' ']'
-                       { $$ = newANONLIST((OP*)NULL);}
+                       { $$ = newANONLIST(NULL);}
        |       HASHBRACK expr ';' '}'  %prec '(' /* { foo => "Bar" } */
                        { $$ = newANONHASH($2); }
        |       HASHBRACK ';' '}'       %prec '(' /* { } (';' by tokener) */
-                       { $$ = newANONHASH((OP*)NULL); }
+                       { $$ = newANONHASH(NULL); }
        |       ANONSUB startanonsub proto subattrlist block            %prec '('
                        { SvREFCNT_inc_simple_void(PL_compcv);
                          $$ = newANONATTRSUB($2, $3, $4, $5); }
@@ -1309,19 +1237,19 @@ myterm  :       '(' expr ')'
 
 /* Basic list expressions */
 optlistexpr:   /* NULL */ %prec PREC_LOW
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       listexpr    %prec PREC_LOW
                        { $$ = $1; }
        ;
 
 optexpr:       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       expr
                        { $$ = $1; }
        ;
 
 optrepl:       /* NULL */
-                       { $$ = (OP*)NULL; }
+                       { $$ = NULL; }
        |       '/' expr
                        { $$ = $2; }
        ;