Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 175 lines (156 sloc) 6.51 kb
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
1 /* parser.h
2 *
2eee27d7 » renormalist
2012-01-17 Bump several file copyright dates
3 * Copyright (c) 2006, 2007, 2009, 2010, 2011 Larry Wall and others
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
4 *
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.
7 *
8 * This file defines the layout of the parser object used by the parser
6cded92d » rhcarvalho
2011-10-09 Fix a 5-year-old typo in a comment
9 * and lexer (perly.c, toke.c).
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
10 */
11
acdf0a21 » Dave Mitchell
2007-01-01 split parser initialisation from parser execution
12 #define YYEMPTY (-2)
13
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
14 typedef struct {
15 YYSTYPE val; /* semantic value */
16 short state;
33703721 » Dave Mitchell
2007-07-16 change #31615 added the new field in the wrong place
17 I32 savestack_ix; /* size of savestack at this state */
8c63ea58 » ggoossen
2009-12-08 Store the PL_compcv instead of the the PL_comppad in parser stack, an…
18 CV *compcv; /* value of PL_compcv when this value was created */
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
19 #ifdef DEBUGGING
20 const char *name; /* token/rule name for -Dpv */
21 #endif
22 } yy_stack_frame;
23
d794b522 » Father Chrysostomos
2012-08-27 Add PL_parser->lex_shared struct; move herelines into it
24 /* Fields that need to be shared with (i.e., visible to) inner lex-
25 ing scopes. */
26 typedef struct yy_lexshared {
27 struct yy_lexshared *ls_prev;
60f40a38 » Father Chrysostomos
2012-08-28 Use PL_parser->lex_shared instead of Sv[IN]VX(PL_linestr)
28 SV *ls_linestr; /* mirrors PL_parser->linestr */
29 char *ls_bufptr; /* mirrors PL_parser->bufptr */
3328ab5a » Father Chrysostomos
2012-08-29 Finish fixing here-docs in re-evals
30 char *re_eval_start; /* start of "(?{..." text */
31 SV *re_eval_str; /* "(?{...})" text */
d794b522 » Father Chrysostomos
2012-08-27 Add PL_parser->lex_shared struct; move herelines into it
32 line_t herelines; /* number of lines in here-doc */
33 } LEXSHARED;
34
22735491 » Dave Mitchell
2007-01-01 split parser stack from parser object
35 typedef struct yy_parser {
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
36
37 /* parser state */
38
22735491 » Dave Mitchell
2007-01-01 split parser stack from parser object
39 struct yy_parser *old_parser; /* previous value of PL_parser */
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
40 YYSTYPE yylval; /* value of lookahead symbol, set by yylex() */
9bd87817 » Nicholas Clark
2007-03-31 Rearrange members of structures to reduce memory size on some
41 int yychar; /* The lookahead symbol. */
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
42
43 /* Number of tokens to shift before error messages enabled. */
44 int yyerrstatus;
45
46 int stack_size;
47 int yylen; /* length of active reduction */
22735491 » Dave Mitchell
2007-01-01 split parser stack from parser object
48 yy_stack_frame *stack; /* base of stack */
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
49 yy_stack_frame *ps; /* current stack frame */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
50
51 /* lexer state */
52
78cdf107 » Zefram
2010-12-11 recursive-descent expression parsing
53 I32 lex_brackets; /* square and curly bracket count */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
54 I32 lex_casemods; /* casemod count */
55 char *lex_brackstack;/* what kind of brackets to pop */
56 char *lex_casestack; /* what kind of case mods in effect */
651b5b28 » Nicholas Clark
2007-04-21 Several members of struct yy_parser can go on a diet. Some I32s were
57 U8 lex_defer; /* state after determined token */
58 bool lex_dojoin; /* doing an array interpolation */
59 U8 lex_expect; /* expect after determined token */
53a7735b » Dave Mitchell
2007-05-04 move PL_expect and PL_copline into the PL_parser structure
60 U8 expect; /* how to interpret ambiguous tokens */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
61 I32 lex_formbrack; /* bracket count at outer format level */
62 OP *lex_inpat; /* in pattern $) and $| are special */
63 OP *lex_op; /* extra info to pass back on op */
64 SV *lex_repl; /* runtime replacement from s/// */
651b5b28 » Nicholas Clark
2007-04-21 Several members of struct yy_parser can go on a diet. Some I32s were
65 U16 lex_inwhat; /* what kind of quoting are we in */
5ed5d9db » Father Chrysostomos
2012-07-03 parser.h: Correct comment explaining last_lop_op
66 OPCODE last_lop_op; /* last named list or unary operator */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
67 I32 lex_starts; /* how many interps done on level */
68 SV *lex_stuff; /* runtime pattern from m// or s/// */
69 I32 multi_start; /* 1st line of multi-line string */
670a9cb2 » Dave Mitchell
2007-05-21 move PL_multi_end into the PL_parser struct
70 I32 multi_end; /* last line of multi-line string */
651b5b28 » Nicholas Clark
2007-04-21 Several members of struct yy_parser can go on a diet. Some I32s were
71 char multi_open; /* delimiter of said string */
72 char multi_close; /* delimiter of said string */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
73 char pending_ident; /* pending identifier lookup */
74 bool preambled;
78cdf107 » Zefram
2010-12-11 recursive-descent expression parsing
75 I32 lex_allbrackets;/* (), [], {}, ?: bracket count */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
76 SUBLEXINFO sublex_info;
d794b522 » Father Chrysostomos
2012-08-27 Add PL_parser->lex_shared struct; move herelines into it
77 LEXSHARED *lex_shared;
bdc0bf6f » Dave Mitchell
2007-04-24 move PL_linestr from the interpreter struct to the parser struct
78 SV *linestr; /* current chunk of src text */
a0dffe9b » Father Chrysostomos
2012-07-03 parser.h: Add comments explaining *bufptr
79 char *bufptr; /* carries the cursor (current parsing
80 position) from one invocation of yylex
81 to the next */
82 char *oldbufptr; /* in yylex, beginning of current token */
83 char *oldoldbufptr; /* in yylex, beginning of previous token */
f06b5848 » Dave Mitchell
2007-05-04 move some more variables into the PL_parser struct:
84 char *bufend;
85 char *linestart; /* beginning of most recently read line */
86 char *last_uni; /* position of last named-unary op */
87 char *last_lop; /* position of last list operator */
1f68b13b » Father Chrysostomos
2012-08-27 parser.h: Document copline with more detail
88 /* copline is used to pass a specific line number to newSTATEOP. It
89 is a one-time line number, as newSTATEOP invalidates it (sets it to
90 NOLINE) after using it. The purpose of this is to report line num-
91 bers in multiline constructs using the number of the first line. */
92 line_t copline;
12bd6ede » Dave Mitchell
2007-05-12 move PL_in_my and PL_in_my_stash into the PL_parser struct
93 U16 in_my; /* we're compiling a "my"/"our" declaration */
bc177e6b » Dave Mitchell
2007-05-05 move PL_lex_state into the PL_parser struct
94 U8 lex_state; /* next token is determined */
1f0c31d7 » Nicholas Clark
2007-07-16 Re-order struct yy_parser to save space on most systems.
95 U8 error_count; /* how many compile errors so far, max 10 */
12bd6ede » Dave Mitchell
2007-05-12 move PL_in_my and PL_in_my_stash into the PL_parser struct
96 HV *in_my_stash; /* declared class of this "my" declaration */
2f9285f8 » Dave Mitchell
2007-05-11 move PL_rsfp into the PL_parser struct
97 PerlIO *rsfp; /* current source file pointer */
5486870f » Dave Mitchell
2007-05-12 move PL_rsfp_filters into the parser struct
98 AV *rsfp_filters; /* holds chain of active source filters */
583c9d5c » Father Chrysostomos
2012-08-06 [perl #114040] Parse formats in interpolating constructs
99 U8 form_lex_state; /* remember lex_state when parsing fmt */
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
100
101 #ifdef PERL_MAD
102 SV *endwhite;
103 I32 faketokens;
104 I32 lasttoke;
105 SV *nextwhite;
106 I32 realtokenstart;
107 SV *skipwhite;
108 SV *thisclose;
109 MADPROP * thismad;
110 SV *thisopen;
111 SV *thisstuff;
112 SV *thistoken;
113 SV *thiswhite;
fb205e7a » Dave Mitchell
2007-05-05 migrate more variables to PL_parser struct:
114
115 /* What we know when we're in LEX_KNOWNEXT state. */
116 NEXTTOKE nexttoke[5]; /* value of next token, if any */
117 I32 curforce;
118 #else
119 YYSTYPE nextval[5]; /* value of next token, if any */
120 I32 nexttype[5]; /* type of next token */
121 I32 nexttoke;
199e78b7 » Dave Mitchell
2007-01-02 move easy lexer state variables into PL_parser
122 #endif
fb205e7a » Dave Mitchell
2007-05-05 migrate more variables to PL_parser struct:
123
7c4baf47 » Dave Mitchell
2007-05-12 save old PL_curcop value in parser struct
124 COP *saved_curcop; /* the previous PL_curcop */
14047fc9 » Dave Mitchell
2007-05-21 move PL_tokenbuf into the PL_parser struct
125 char tokenbuf[256];
7c4baf47 » Dave Mitchell
2007-05-12 save old PL_curcop value in parser struct
126
78cdf107 » Zefram
2010-12-11 recursive-descent expression parsing
127 U8 lex_fakeeof; /* precedence at which to fake EOF */
286a76ab » Nicholas Clark
2012-02-23 In struct yy_parser, change lex_flags to a U8, from part of a bitfield.
128 U8 lex_flags;
7ad221d3 » Father Chrysostomos
2011-11-04 Merge some parser fields
129 PERL_BITFIELD16 in_pod:1; /* lexer is within a =pod section */
130 PERL_BITFIELD16 filtered:1; /* source filters in evalbytes */
5912531f » Dave Mitchell
2006-12-18 move parser state into new parser object, PL_parser
131 } yy_parser;
132
f0e67a1d » Zefram
2009-11-15 lexer API
133 /* flags for lexer API */
134 #define LEX_STUFF_UTF8 0x00000001
135 #define LEX_KEEP_PREVIOUS 0x00000002
17e00314 » Father Chrysostomos
2011-10-29 parser.h: Rearrange constants
136
27fcb6ee » Father Chrysostomos
2011-03-29 [perl #87064] eval no longer shares filters
137 #ifdef PERL_CORE
138 # define LEX_START_SAME_FILTER 0x00000001
60d63348 » Father Chrysostomos
2011-11-04 Make source filters work in evalbytes
139 # define LEX_IGNORE_UTF8_HINTS 0x00000002
140 # define LEX_EVALBYTES 0x00000004
0abcdfa4 » Father Chrysostomos
2011-11-06 Avoid redundant copies in string evals
141 # define LEX_START_COPIED 0x00000008
87606032 » Nicholas Clark
2012-02-24 The parser should always close the file handle that it opened.
142 # define LEX_DONT_CLOSE_RSFP 0x00000010
60d63348 » Father Chrysostomos
2011-11-04 Make source filters work in evalbytes
143 # define LEX_START_FLAGS \
0abcdfa4 » Father Chrysostomos
2011-11-06 Avoid redundant copies in string evals
144 (LEX_START_SAME_FILTER|LEX_START_COPIED \
87606032 » Nicholas Clark
2012-02-24 The parser should always close the file handle that it opened.
145 |LEX_IGNORE_UTF8_HINTS|LEX_EVALBYTES|LEX_DONT_CLOSE_RSFP)
27fcb6ee » Father Chrysostomos
2011-03-29 [perl #87064] eval no longer shares filters
146 #endif
f0e67a1d » Zefram
2009-11-15 lexer API
147
361d9b55 » Zefram
2010-10-24 function to parse isolated label
148 /* flags for parser API */
149 #define PARSE_OPTIONAL 0x00000001
150
78cdf107 » Zefram
2010-12-11 recursive-descent expression parsing
151 /* values for lex_fakeeof */
152 enum {
153 LEX_FAKEEOF_NEVER, /* don't fake EOF */
154 LEX_FAKEEOF_CLOSING, /* fake EOF at unmatched closing punctuation */
155 LEX_FAKEEOF_NONEXPR, /* ... and at token that can't be in expression */
156 LEX_FAKEEOF_LOWLOGIC, /* ... and at low-precedence logic operator */
157 LEX_FAKEEOF_COMMA, /* ... and at comma */
158 LEX_FAKEEOF_ASSIGN, /* ... and at assignment operator */
159 LEX_FAKEEOF_IFELSE, /* ... and at ?: operator */
160 LEX_FAKEEOF_RANGE, /* ... and at range operator */
161 LEX_FAKEEOF_LOGIC, /* ... and at logic operator */
162 LEX_FAKEEOF_BITWISE, /* ... and at bitwise operator */
163 LEX_FAKEEOF_COMPARE, /* ... and at comparison operator */
164 LEX_FAKEEOF_MAX
165 };
166
e9a8c099 » Marcus Holland-Moritz
2008-01-01 Add editor blocks to some header files.
167 /*
168 * Local variables:
169 * c-indentation-style: bsd
170 * c-basic-offset: 4
14d04a33 » rjbs
2012-05-25 update the editor hints for spaces, not tabs
171 * indent-tabs-mode: nil
e9a8c099 » Marcus Holland-Moritz
2008-01-01 Add editor blocks to some header files.
172 * End:
173 *
14d04a33 » rjbs
2012-05-25 update the editor hints for spaces, not tabs
174 * ex: set ts=8 sts=4 sw=4 et:
e9a8c099 » Marcus Holland-Moritz
2008-01-01 Add editor blocks to some header files.
175 */
Something went wrong with that request. Please try again.