summaryrefslogtreecommitdiff
path: root/toke.c
Commit message (Collapse)AuthorAgeFilesLines
* Silence some data truncation compiler warningsJan Dubois2010-12-161-1/+1
|
* permit labels to be stackedZefram2010-12-131-1/+1
| | | | | Liberalise label syntax a little more, by allowing multiple adjacent labels with no intervening statements, as in "foo: bar: baz:".
* recursive-descent expression parsingZefram2010-12-111-50/+451
| | | | | | New API functions parse_fullexpr(), parse_listexpr(), parse_termexpr(), and parse_arithexpr(), to parse an expression at various precedence levels.
* toke.c: Fix EBCDIC problemKarl Williamson2010-12-071-2/+2
| | | | | | Commit 356979f4a7d780fd67a92a9ca6c8659bd12e7168 failed to include two instances in toke.c that needed the same treatment, i.e., converting properly from I8 to native.
* toke.c: highlight problematic-mentioning commentKarl Williamson2010-12-071-3/+3
|
* [perl #77762] Constant assignment warningFather Chrysostomos2010-11-301-0/+1
| | | | | | | | | | | | With this patch: $ ./perl -we 'sub A () {1}; if (0) {my $foo = A or die}' $ ./perl -we 'sub A () {1}; if (0) {my $foo = 1 or die}' Found = in conditional, should be == at -e line 1. Since the value of a constant may not be known at the time the program is written, it should be perfectly acceptable to do a constant assign- ment in a conditional.
* In S_scan_const(), use my_snprintf() instead of my_sprintf().Nicholas Clark2010-11-301-2/+4
| | | | Paranoid linkers warn about using sprintf(), and rightly so.
* Make my $pi := 4; a syntax error.Nicholas Clark2010-11-281-1/+2
| | | | | Previously it interpreted := as an empty attribute list, and issued a deprecation warning. This change permits := to be used as a binding operator.
* Deprecate ?PATTERN? without explicit m operatorZefram2010-11-241-0/+2
| | | | | | | | | | Deprecate ?PATTERN?, recommending the equivalent m?PATTERN? syntax, in order to eventually allow the question mark to be used in new operators that would currently be ambiguous. (With minor reconciliation edits by David Golden) Signed-off-by: David Golden <dagolden@cpan.org>
* y///rFather Chrysostomos2010-11-021-2/+9
|
* In S_scan_const(), use the return value of my_sprintf() to avoid a strlen().Nicholas Clark2010-10-281-4/+4
| | | | Brought to you by the campaign for the elimination of strlen().
* function to parse isolated labelZefram2010-10-251-4/+91
| | | | | | | New API function parse_label() parses a label, separate from statements. If a label has not already been lexed and queued up, it does not use yylex(), but parses the label itself at the character level, to avoid unwanted lexing past an absent optional label.
* function to parse unlabelled statementZefram2010-10-251-2/+40
| | | | | New API function parse_barestmt() parses a pure statement, with no label, and returns just the statement's core ops, not attaching a state op.
* S_tokeq()'s fast scan loop should terminate on \\ not \Nicholas Clark2010-10-221-1/+2
| | | | | | | As-was, it would drop out of the scanner into the backslashed-backslash processing loop earlier than need be, and hence would be copying the octets of strings (in place) as soon as any backslash had been seen. Now it defers copying until copying is actually unavoidable.
* Add single-term prototypeDavid Golden2010-10-211-2/+2
| | | | | | | | | | | | | | | | The C<+> prototype is a special alternative to C<$> that will act like C<\[@%]> when given a literal array or hash variable, but will otherwise force scalar context on the argument. This is useful for functions which should accept either a literal array or an array reference as the argument: sub smartpush (+@) { my $aref = shift; die "Not an array or arrayref" unless ref $aref eq 'ARRAY'; push @$aref, @_; } When using the C<+> prototype, your function must check that the argument is of an acceptable type.
* function to parse Perl code blockZefram2010-10-211-16/+57
| | | | | New API function parse_block() parses a code block, including surrounding braces. The block is a lexical scope, but not inherently a dynamic scope.
* handle bracket stack better in recdescent parsingZefram2010-10-211-14/+54
| | | | | | | | | | | | | When recursing into the parser for recursive-descent parsing, put a special entry on the bracket stack that generates a fake EOF if a closing bracket belonging to an outer parser frame is seen. This keeps the bracket stack balanced across a parse_stmtseq() frame, fixing [perl #78222]. If a recursive-descent parser frame ends by yyunlex()ing an opening bracket, pop its entry off the bracket stack and stash it in the forced-token queue, to be revived when the token is re-lexed. This keeps the bracket stack balanced across a parse_fullstmt() frame.
* add lex_start to the APIZefram2010-10-211-11/+24
| | | | | lex_start() is added to the API, marked experimental, and documented. It also gains a flags parameter for foreseeable future use.
* avoid side-effecting source held in scalarZefram2010-10-211-6/+1
| | | | | | | | Syntax plugins can modify the source being parsed. It's fine for them to modify the lexer buffer, but this must not be the same scalar that was supplied to lex_start() and may be in use outside. Therefore always copy the scalar in lex_start() rather than just referencing it. Fixes [perl #78358].
* remove redundant lex_endZefram2010-10-211-11/+0
| | | | | | | The lex_end() function is redundant, because the lexer context object is actually finalised by parser_free(), triggered by the save stack. The lex_end() function has historically been empty, except when the PL_doextract global was being misused to store lexer state.
* replace PL_doextract with better kinds of variableZefram2010-10-211-7/+7
| | | | | | | | PL_doextract had two unrelated jobs, neither best served by an interpreter global variable. The first was to track the -x command-line switch. That is replaced with a local variable in S_parse_body(). The second was to track whether the lexer is in the middle of a =pod section. That is replaced with an element in PL_parser.
* remove filter inheritance option from lex_startZefram2010-10-211-6/+2
| | | | | | | | The only uses of lex_start that had the new_filter parameter false, to make the new lexer context share source filters with the previous lexer context, were uses with rsfp null, which therefore never invoked source filters. Inheriting source filters from a logically unrelated file seems like a silly idea anyway.
* APIify op list constructorsZefram2010-10-121-7/+7
| | | | | | Put into the API op_append_elem, op_prepend_elem, and op_append_list. All renamed from op_-less internal names. Parameter types for op_append_list changed to match the rest of the op API and avoid some casting.
* plugin mechanism to rewrite calls to a subroutineZefram2010-10-101-18/+1
| | | | | | | | | | | | | | | | | | | | | | | | New magic type PERL_MAGIC_checkcall attaches a function to a CV, which will be called as the second half of the op checker for an entersub op calling that CV. Default state, in the absence of this magic, is to process the CV's prototype if it has one, or apply list context to all the arguments if not. New API functions cv_get_call_checker() and cv_set_call_checker() provide a clean interface to this facility, hiding the internal use of magic. Expose in the API the new functions rv2cv_op_cv(), ck_entersub_args_list(), ck_entersub_args_proto(), and ck_entersub_args_proto_or_list(), which are meaningful segments of standard entersub op checking and are likely to be useful in plugged-in call checker functions. Expose new API function op_contextualize(), which is a public interface to the internal scalar()/list()/scalarvoid() functions. This API is likely to be required in most plugged-in call checker functions. Incidentally add new function mg_free_type(), in the API, which will remove magic of one type from an SV. (mg_free() removes all magic, and there isn't anything else more selective.)
* Create populate_isa() to de-duplicate logic to populate @ISA.Nicholas Clark2010-10-091-17/+7
| | | | | | | Previously yylex() was conditionally populating @AnyDBM_File::ISA (if it was not set, and the token dbmopen was seen), and init_predump_symbols() was populating @IO::File::ISA (unconditionally, but this is so early that nothing previously could have set it). This refactoring eliminates code duplication.
* Move the automatic instantiation of @AnyDBM_File::ISA to Perl_yylex()Nicholas Clark2010-10-091-1/+17
| | | | | | | | | | | case KEY_dbmopen in Perl_yylex() has always had special-case code to create @AnyDBM_File::ISA, using GV_ADDMULTI. S_gv_magicalize_isa() [part of Perl_gv_fetchpvn_flags()] has special case code to spot "AnyDBM_File::ISA" being created with GV_ADDMULTI, and populate the variable if it is empty. Grouping the special case code in one place makes more sense. Removing the special case code from gv.c means that there is no longer a check clause in the code path for *every* package's @ISA initialisation.
* [PATCH] function to parse Perl statement sequenceZefram2010-10-041-0/+46
| | | | | New API function parse_stmtseq() parses a sequence of statements, up to closing brace or EOF.
* toke.c: call regcurly instead of duplicating codeKarl Williamson2010-10-031-11/+2
| | | | Remove code that duplicates regcurly()
* systematically provide pv/pvn/pvs/sv quartetsZefram2010-09-281-2/+31
| | | | | Anywhere an API function takes a string in pvn form, ensure that there are corresponding pv, pvs, and sv APIs.
* Extract regcurly as a static inline function.Andy Dougherty2010-09-221-0/+1
| | | | | | | This patch extracts regcurly from regcomp.c and converts it to a static inline function in a new file dquote_static.c that is now #included by regcomp.c and toke.c. This change will require 'make regen'.
* Shorten external symbol name for VMSFlorian Ragwitz2010-09-111-2/+2
| | | | | | VMS seems to have a 31 character limitation for external symbols. To be able to fit into that, rename 'coerce_qwlist_to_paren_list' to 'munge_qwlist_to_paren_list'.
* fix MAD breakage caused by qw patchZefram2010-09-111-0/+1
| | | | | ea25a9b2cf73948b1e8c5675de027e0ad13277bd broke MAD due to incorrect usage of the token-forcing mechanism.
* make qw(...) first-class syntaxZefram2010-09-081-10/+24
| | | | | | | | | | This makes a qw(...) list literal a distinct token type for the parser, where previously it was munged into a "(",THING,")" sequence. The change means that qw(...) can't accidentally supply parens to parts of the grammar that want real parens. Due to many bits of code taking advantage of that by "foreach my $x qw(...) {}", this patch also includes a hack to coerce qw(...) to the old-style parenthesised THING, emitting a deprecation warning along the way.
* function interface to parse Perl statementZefram2010-09-061-13/+59
| | | | | | | | | | | | | yyparse() becomes reentrant. The yacc stack and related resources are allocated in yyparse(), rather than in lex_start(), and they are localised to yyparse(), preserving their values from any outer parser. yyparse() now takes a parameter which determines which production it will parse at the top level. New API function parse_fullstmt() uses this facility to parse just a single statement. The top-level single-statement production that is used for this then messes with the parser's head so that the parsing stops without seeing EOF, and any lookahead token seen after the statement is pushed back to the lexer.
* Avoid needless use of UTF8=1 format [RT#56336]Eric Brine2010-08-311-13/+6
| | | | | Some literals (e.g. q'abc') don't set the UTF8 flag for pure ASCII literals. Others (e.g. -abc) do. This should be consistent.
* Remove CALL_FPTR and CPERLscope.Ben Morrow2010-08-201-1/+1
| | | | | | | | | | | | | | | | These are left from PERL_OBJECT, which was an implementation of multiplicity using C++ objects. PERL_OBJECT was removed in 5.8, but the macros seem to have been cargo-culted all over the core (including in places where they would have been inappropriate originally). Since they now do exactly nothing, it's cleaner to remove them. I have left the definitions in perl.h, under #ifndef PERL_CORE, since some CPAN XS code uses them (also often incorrectly). I have also left STATIC alone, since it seems potentially more useful and is much more ingrained. The only appearance of these macros this patch doesn't touch is in Devel-PPPort, because that's a CPAN module.
* [perl #75904] \$ prototype does not make a unary functionFather Chrysostomos2010-08-111-2/+19
| | | | | | | | | | | | | | | | | | This fixes this problem : $ perl -le' sub foo($) { print "foo" }; foo $_, exit' foo $ perl -le' sub foo(\$) { print "foo" }; foo $_, exit' Too many arguments for main::foo at -e line 1, at EOF Execution of -e aborted due to compilation errors. for all those prototypes: * \sigil \[...] ;$ ;* ;\sigil ;\[...]
* Change function signature of grok_bslash_oKarl Williamson2010-07-271-2/+3
| | | | The previous return value where NULL meant OK is outside-the-norm.
* Correct comment in toke.cKarl Williamson2010-07-271-1/+1
|
* Normalize formatting of "Ambiguous call resolved as CORE::%s(), qualify as ↵James Mastros2010-07-261-2/+3
| | | | such or use &" in toke.c, so t/porting/diag.t can find it.
* Add \o{} escapeKarl Williamson2010-07-171-0/+14
| | | | | | | | | | This commit adds the new construct \o{} to express a character constant by its octal ordinal value, along with ancillary tests and documentation. A function to handle this is added to util.c, and it is called from the 3 parsing places it could occur. The function is a candidate for in-lining, though I doubt that it will ever be used frequently.
* Code for allowing uppercase X/B in hexadecimal/binary numbers (#76296).Bo Lindbergh2010-07-061-2/+2
| | | | Signed-off-by: David Golden <dagolden@cpan.org>
* In Perl_lex_start(), use newSVpvn_flags() to reduce source and object size.Nicholas Clark2010-07-051-2/+2
|
* eval $overloaded can crashDavid Mitchell2010-07-031-2/+3
| | | | | | | Perl_lex_start() assumes that the SV passed to it is a well-behaved string that it can do PVX() stuff to. If it's actually a ref to an overloaded object, it can crash and burn. Fixed by creating a stringified copy of the SV if necessary.
* In Perl_filter_del(), no need to NULL IoANY(datasv).Nicholas Clark2010-06-301-2/+0
| | | | | Perl_sv_clear() understands the IOf_FAKE_DIRP flag, and when set won't treat IoANY() as a a pointer to a directory handle that needs closing.
* Deprecate no space after s/a/b/ and keywordKarl Williamson2010-06-281-1/+7
| | | | | Pattern replacements need to have the deprecation added; the prior patch on this ticket only changed m/a/keyword; this adds the s/a/b/keyword
* Add clarifying comment to toke.cKarl Williamson2010-06-281-1/+2
|
* RT 75902: Add prototypes for tie() and untie() to allow overloadingFather Chrysostomos2010-06-251-3/+3
|
* Deprecate no space between pattern, following wordKarl Williamson2010-06-181-0/+6
| | | | | | | This patch raises a deprecated warning on constructs like $result = $a =~ m/$foo/sand $bar; which means $result = $a =~ m/$foo/s and $bar;
* Parameters for * in *printf must be int - add a cast to ensure this.Nicholas Clark2010-06-101-1/+2
| | | | Fixes a (legitimate) compiler warning present since 6e1bad6cc227c8e8.