3 * Copyright (c) 2006, 2007, 2009, 2010, 2011 Larry Wall and others
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8 * This file defines the layout of the parser object used by the parser
9 * and lexer (perly.c, toke.c).
15 YYSTYPE val; /* semantic value */
17 I32 savestack_ix; /* size of savestack at this state */
18 CV *compcv; /* value of PL_compcv when this value was created */
20 const char *name; /* token/rule name for -Dpv */
24 /* Fields that need to be shared with (i.e., visible to) inner lex-
26 typedef struct yy_lexshared {
27 struct yy_lexshared *ls_prev;
28 line_t herelines; /* number of lines in here-doc */
31 typedef struct yy_parser {
35 struct yy_parser *old_parser; /* previous value of PL_parser */
36 YYSTYPE yylval; /* value of lookahead symbol, set by yylex() */
37 int yychar; /* The lookahead symbol. */
39 /* Number of tokens to shift before error messages enabled. */
43 int yylen; /* length of active reduction */
44 yy_stack_frame *stack; /* base of stack */
45 yy_stack_frame *ps; /* current stack frame */
49 I32 lex_brackets; /* square and curly bracket count */
50 I32 lex_casemods; /* casemod count */
51 char *lex_brackstack;/* what kind of brackets to pop */
52 char *lex_casestack; /* what kind of case mods in effect */
53 U8 lex_defer; /* state after determined token */
54 bool lex_dojoin; /* doing an array interpolation */
55 U8 lex_expect; /* expect after determined token */
56 U8 expect; /* how to interpret ambiguous tokens */
57 I32 lex_formbrack; /* bracket count at outer format level */
58 OP *lex_inpat; /* in pattern $) and $| are special */
59 OP *lex_op; /* extra info to pass back on op */
60 SV *lex_repl; /* runtime replacement from s/// */
61 U16 lex_inwhat; /* what kind of quoting are we in */
62 OPCODE last_lop_op; /* last named list or unary operator */
63 I32 lex_starts; /* how many interps done on level */
64 SV *lex_stuff; /* runtime pattern from m// or s/// */
65 I32 multi_start; /* 1st line of multi-line string */
66 I32 multi_end; /* last line of multi-line string */
67 char multi_open; /* delimiter of said string */
68 char multi_close; /* delimiter of said string */
69 char pending_ident; /* pending identifier lookup */
71 I32 lex_allbrackets;/* (), [], {}, ?: bracket count */
72 SUBLEXINFO sublex_info;
73 LEXSHARED *lex_shared;
74 SV *linestr; /* current chunk of src text */
75 char *bufptr; /* carries the cursor (current parsing
76 position) from one invocation of yylex
78 char *oldbufptr; /* in yylex, beginning of current token */
79 char *oldoldbufptr; /* in yylex, beginning of previous token */
81 char *linestart; /* beginning of most recently read line */
82 char *last_uni; /* position of last named-unary op */
83 char *last_lop; /* position of last list operator */
84 /* copline is used to pass a specific line number to newSTATEOP. It
85 is a one-time line number, as newSTATEOP invalidates it (sets it to
86 NOLINE) after using it. The purpose of this is to report line num-
87 bers in multiline constructs using the number of the first line. */
89 U16 in_my; /* we're compiling a "my"/"our" declaration */
90 U8 lex_state; /* next token is determined */
91 U8 error_count; /* how many compile errors so far, max 10 */
92 HV *in_my_stash; /* declared class of this "my" declaration */
93 PerlIO *rsfp; /* current source file pointer */
94 AV *rsfp_filters; /* holds chain of active source filters */
95 U8 form_lex_state; /* remember lex_state when parsing fmt */
111 /* What we know when we're in LEX_KNOWNEXT state. */
112 NEXTTOKE nexttoke[5]; /* value of next token, if any */
115 YYSTYPE nextval[5]; /* value of next token, if any */
116 I32 nexttype[5]; /* type of next token */
120 COP *saved_curcop; /* the previous PL_curcop */
123 U8 lex_fakeeof; /* precedence at which to fake EOF */
125 PERL_BITFIELD16 in_pod:1; /* lexer is within a =pod section */
126 PERL_BITFIELD16 filtered:1; /* source filters in evalbytes */
129 /* flags for lexer API */
130 #define LEX_STUFF_UTF8 0x00000001
131 #define LEX_KEEP_PREVIOUS 0x00000002
134 # define LEX_START_SAME_FILTER 0x00000001
135 # define LEX_IGNORE_UTF8_HINTS 0x00000002
136 # define LEX_EVALBYTES 0x00000004
137 # define LEX_START_COPIED 0x00000008
138 # define LEX_DONT_CLOSE_RSFP 0x00000010
139 # define LEX_START_FLAGS \
140 (LEX_START_SAME_FILTER|LEX_START_COPIED \
141 |LEX_IGNORE_UTF8_HINTS|LEX_EVALBYTES|LEX_DONT_CLOSE_RSFP)
144 /* flags for parser API */
145 #define PARSE_OPTIONAL 0x00000001
147 /* values for lex_fakeeof */
149 LEX_FAKEEOF_NEVER, /* don't fake EOF */
150 LEX_FAKEEOF_CLOSING, /* fake EOF at unmatched closing punctuation */
151 LEX_FAKEEOF_NONEXPR, /* ... and at token that can't be in expression */
152 LEX_FAKEEOF_LOWLOGIC, /* ... and at low-precedence logic operator */
153 LEX_FAKEEOF_COMMA, /* ... and at comma */
154 LEX_FAKEEOF_ASSIGN, /* ... and at assignment operator */
155 LEX_FAKEEOF_IFELSE, /* ... and at ?: operator */
156 LEX_FAKEEOF_RANGE, /* ... and at range operator */
157 LEX_FAKEEOF_LOGIC, /* ... and at logic operator */
158 LEX_FAKEEOF_BITWISE, /* ... and at bitwise operator */
159 LEX_FAKEEOF_COMPARE, /* ... and at comparison operator */
165 * c-indentation-style: bsd
167 * indent-tabs-mode: nil
170 * ex: set ts=8 sts=4 sw=4 et: