Skip to content

Commit ec8fb4c

Browse files
committed
Merge branch Generalize S_parse_ident' into blead
This series of commits documents, and generalizes this function so that it can be called in more circumstances; the final commit calls it from one such place, as a demonstration. This includes adding a flag to it that allows code to be moved from S_scan_ident to this function, and then called from a second place, eliminating near-duplication. The goal is to centralize to here the sort of handling of names, like identifiers, so changes can be made in just one place, and we can get rid of the other places which have slightly different rules from each other.
2 parents 3450d19 + e75a2dc commit ec8fb4c

File tree

5 files changed

+250
-148
lines changed

5 files changed

+250
-148
lines changed

embed.fnc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,8 +6142,7 @@ S |char * |force_version |NN char *s \
61426142
|int guessing
61436143
S |char * |force_word |NN char *start \
61446144
|int token \
6145-
|int check_keyword \
6146-
|int allow_pack
6145+
|U32 flags
61476146
RS |SV * |get_and_check_backslash_N_name_wrapper \
61486147
|SPTR const char *s \
61496148
|EPTRQ const char * const e
@@ -6177,12 +6176,17 @@ So |SV * |new_constant |NULLOK const char *s \
61776176
|NULLOK const char *type \
61786177
|STRLEN typelen \
61796178
|NULLOK const char **error_msg
6180-
S |void |parse_ident |NN char **s \
6179+
S |char * |parse_ident |SPTR const char *s \
6180+
|EPTRQ const char * const s_end \
61816181
|SPTR char **d \
6182-
|EPTRQ char * const e \
6183-
|int allow_package \
6182+
|EPTR char * const e \
6183+
|bool is_utf8 \
6184+
|U32 flags
6185+
S |char * |parse_ident_no_copy \
6186+
|SPTR const char *s \
6187+
|EPTR const char * const s_end \
61846188
|bool is_utf8 \
6185-
|bool check_dollar
6189+
|U32 flags
61866190
S |int |pending_ident
61876191
RS |char * |scan_const |NN char *start
61886192
RS |char * |scan_formline |NN char *s

embed.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@
16801680
# define force_next(a) S_force_next(aTHX_ a)
16811681
# define force_strict_version(a) S_force_strict_version(aTHX_ a)
16821682
# define force_version(a,b) S_force_version(aTHX_ a,b)
1683-
# define force_word(a,b,c,d) S_force_word(aTHX_ a,b,c,d)
1683+
# define force_word(a,b,c) S_force_word(aTHX_ a,b,c)
16841684
# define get_and_check_backslash_N_name_wrapper(a,b) S_get_and_check_backslash_N_name_wrapper(aTHX_ a,b)
16851685
# define incline(a,b) S_incline(aTHX_ a,b)
16861686
# define intuit_method(a,b,c) S_intuit_method(aTHX_ a,b,c)
@@ -1689,6 +1689,7 @@
16891689
# define lop(a,b,c,d) S_lop(aTHX_ a,b,c,d)
16901690
# define missingterm(a,b) S_missingterm(aTHX_ a,b)
16911691
# define parse_ident(a,b,c,d,e,f) S_parse_ident(aTHX_ a,b,c,d,e,f)
1692+
# define parse_ident_no_copy(a,b,c,d) S_parse_ident_no_copy(aTHX_ a,b,c,d)
16921693
# define pending_ident() S_pending_ident(aTHX)
16931694
# define scan_const(a) S_scan_const(aTHX_ a)
16941695
# define scan_formline(a) S_scan_formline(aTHX_ a)

parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#define YYEMPTY (-2)
13+
#define PERL_IDENTIFIER_LENGTH (256 * MAX_UNICODE_UTF8_BYTES)
1314

1415
typedef struct {
1516
YYSTYPE val; /* semantic value */
@@ -112,7 +113,7 @@ typedef struct yy_parser {
112113
U8 lex_fakeeof; /* precedence at which to fake EOF */
113114
U8 lex_flags;
114115
COP *saved_curcop; /* the previous PL_curcop */
115-
char tokenbuf[ 256 * MAX_UNICODE_UTF8_BYTES ];
116+
char tokenbuf[ PERL_IDENTIFIER_LENGTH ];
116117
line_t herelines; /* number of lines in here-doc */
117118
line_t preambling; /* line # when processing $ENV{PERL5DB} */
118119

proto.h

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)