summaryrefslogtreecommitdiff
path: root/perly.y
Commit message (Collapse)AuthorAgeFilesLines
* Bump several file copyright datesSteffen Schwigon2012-01-191-1/+1
| | | | | | | Sync copyright dates with actual changes according to git history. [Plus run regen_perly.h to update the SHA-256 checksums, and regen/regcharclass.pl to update regcharclass.h]
* [perl #95546] Allow () after __FILE__, etc.Father Chrysostomos2011-08-121-1/+8
| | | | | | | | This commit makes the __FILE__, __LINE__ and __PACKAGE__ token parse the same way as nullary functions. It adds two extra rules to perly.y to allow the op to be created in toke.c, instead of directly inside the parser.
* APIify pad functionsZefram2011-07-121-1/+1
| | | | | | | Move several pad functions into the core API. Document the pad functions more consistently for perlapi. Fix the interface issues around delimitation of lexical variable names, providing _pvn, _pvs, _pv, and _sv forms of pad_add_name and pad_findmy.
* Fix a confusing comment in perly.yFather Chrysostomos2011-06-031-1/+1
| | | | There’s no arrow there.
* permit labels to be stackedZefram2010-12-131-23/+21
| | | | | Liberalise label syntax a little more, by allowing multiple adjacent labels with no intervening statements, as in "foo: bar: baz:".
* rename some grammar productions for clarityZefram2010-12-121-20/+20
| | | | | | | Some of the names for types of expression were misleading. Rename "listexpr"->"optlistexpr", "listexprcom"->"optexpr", and "argexpr"->"listexpr" to make them more accurately descriptive and more consistent.
* recursive-descent expression parsingZefram2010-12-111-1/+10
| | | | | | New API functions parse_fullexpr(), parse_listexpr(), parse_termexpr(), and parse_arithexpr(), to parse an expression at various precedence levels.
* [perl #78586] Bleadperl eae48c89 breaks TIMB/Devel-NYTProf-4.05.tar.gzZefram2010-11-111-1/+0
| | | | | | | | | | | | | | | | | | | > $ perl -d:Trace <<END > warn "1"; > { > warn "3"; > } > warn "5"; > END > >> -:1: warn "1"; > 1 at - line 1. > >> -:5: warn "5"; <== wrong > >> -:3: warn "3"; > 3 at - line 3. > >> -:5: warn "5"; > 5 at - line 5. I believe this is fixed by a one line change (plus `make regen_perly`):
* refactor GRAMPROG grammar slightlyZefram2010-11-071-16/+10
| | | | | Shift the structure of the GRAMPROG production (whole-file grammar) to more closely match that of the other top-level productions.
* new API functions op_scope and op_lvalueZefram2010-10-261-18/+25
| | | | | | The function scope() goes into the API as op_scope(), and mod() goes into the API as op_lvalue(). Both marked experimental, because their behaviour is a little quirky and not trivially dequirkable.
* function to parse unlabelled statementZefram2010-10-251-1/+13
| | | | | 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.
* stop passing line numbers into op constructor functionsZefram2010-10-251-15/+12
| | | | | | | | | Remove the line number parameter from newWHILEOP() and newFOROP() functions. Instead, the line number for the impending COP is set by parser code after constructing the ops. (In fact the parser was doing this anyway in most cases.) This brings newWHILEOP() and newFOROP() in line with the other op constructors, in that they do not concern themselves with COPs.
* refactor and regularise label/statement grammarZefram2010-10-251-325/+241
| | | | | | | | | | | | | | | | | | | | Refactoring of the grammar around statements. New production <barestmt> encompasses a statement without label. It includes all statement types, including declarations, with no unnecessary intermediate non-terminals. It generates an op tree for the statement's content, with no leading state op. The <fullstmt> production has just one rule, consisting of optional label followed by <barestmt>. It puts a state op on the front of the statement's content ops. To support the regular statement op structure, the op sequence for for(;;) loops no longer has a second state op between the initialisation and the loop. Instead, the unstack op type is slightly adapted to achieve the stack clearing without a state op. The newFOROP() constructor function no longer generates a state op, that now being the job of the <fullstmt> production. Consequently it no longer takes a parameter stating what label is to go in the state op. This brings it in line with the other op constructors.
* permit labels to appear before declarationsZefram2010-10-231-28/+24
| | | | | | | | Include <label> in productions before <decl> and <package_block>. This means that labels can now appear at the beginning of all statement-like things. There was no technical reason for the restriction of labels to substantive statements, and that restriction in any case couldn't be applied to PLUGSTMT-based plugged-in declarations.
* function to parse Perl code blockZefram2010-10-211-1/+12
| | | | | New API function parse_block() parses a code block, including surrounding braces. The block is a lexical scope, but not inherently a dynamic scope.
* fix and test PL_expect in recdescent parsingZefram2010-10-211-2/+6
| | | | | Set PL_expect at the start of parse_fullstmt() as well as at the start of parse_stmtseq(). Test both.
* handle bracket stack better in recdescent parsingZefram2010-10-211-18/+2
| | | | | | | | | | | | | 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.
* APIify op list constructorsZefram2010-10-121-32/+28
| | | | | | 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.
* [PATCH] function to parse Perl statement sequenceZefram2010-10-041-2/+27
| | | | | New API function parse_stmtseq() parses a sequence of statements, up to closing brace or EOF.
* Shorten external symbol name for VMSFlorian Ragwitz2010-09-111-1/+1
| | | | | | 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'.
* make qw(...) first-class syntaxZefram2010-09-081-21/+38
| | | | | | | | | | 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-5/+28
| | | | | | | | | | | | | 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.
* remove dead listexprcom production from grammarZefram2010-08-311-11/+0
| | | | | The third production of <listexprcom>, "expr ','", could never be invoked, because <expr> can already end with arbitrarily many commas.
* fix MAD handling of package block syntaxZefram2010-05-231-2/+1
| | | | | | There was a broken TOKEN_GETMAD attempting to handle the label preceding a package-block statement, where no label is actually possible. The correct behaviour for no label is a no-op, so just remove the TOKEN_GETMAD.
* fix SEGV with eval("package Foo {")Zefram2010-05-201-1/+11
| | | | | | OPs relating to the package name and version were subject to double freeing during error recovery from an incomplete package block. Fixed by using the op_latefree mechanism to shift the op free time.
* support "package Foo { ... }"Zefram2010-05-201-1/+22
| | | | | | Package block syntax limits the scope of the package declaration to the attached block. It's cleaner than requiring the declaration to come inside the block.
* [perl #22977] Bug in format/writeZefram2009-12-151-1/+7
|
* -Dmad broken for c++Tony Cook2009-12-011-3/+3
| | | | | | | | | | | | | On Tue, Dec 01, 2009 at 08:22:38AM +0100, H.Merijn Brand wrote: > perly.y: In function 'int Perl_madparse(PerlInterpreter*)': > perly.y:335: error: cast from 'TOKEN*' to 'line_t' loses precision > perly.y:348: error: cast from 'TOKEN*' to 'line_t' loses precision > perly.y:430: error: cast from 'TOKEN*' to 'line_t' loses precision Uses the same mechanism used in if, unless to retrieve an ival set in toke.c Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
* Add length and flags arguments to Perl_allocmy().Nicholas Clark2009-11-091-1/+1
| | | | | | Currently no flags bits are used, and the length is cross-checked against strlen() on the pointer, but the intent is to re-work the entire pad API to be UTF-8 aware, from the current situation of char * pointers only.
* Implement facility to plug in syntax triggered by keywordsJesse Vincent2009-11-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Date: Tue, 27 Oct 2009 01:29:40 +0000 From: Zefram <zefram@fysh.org> To: perl5-porters@perl.org Subject: bareword sub lookups Attached is a patch that changes how the tokeniser looks up subroutines, when they're referenced by a bareword, for prototype and const-sub purposes. Formerly, it has looked up bareword subs directly in the package, which is contrary to the way the generated op tree looks up the sub, via an rv2cv op. The patch makes the tokeniser generate the rv2cv op earlier, and dig around in that. The motivation for this is to allow modules to hook the rv2cv op creation, to affect the name->subroutine lookup process. Currently, such hooking affects op execution as intended, but everything goes wrong with a bareword ref where the tokeniser looks at some unrelated CV, or a blank space, in the package. With the patch in place, an rv2cv hook correctly affects the tokeniser and therefore the prototype-based aspects of parsing. The patch also changes ck_subr (which applies the argument context and checking parts of prototype behaviour) to handle subs referenced by an RV const op inside the rv2cv, where formerly it would only handle a gv op inside the rv2cv. This is to support the most likely kind of modified rv2cv op. [This commit includes the Makefile.PL for XS-APITest-KeywordRPN missing from the original patch, as well as updates to perldiag.pod and a MANIFEST sort]
* Restore MAD handling of package statementsRafael Garcia-Suarez2009-10-081-10/+8
| | | | | Since the version seems unused by MAD in "use", do the same for "package"...
* Add 'package NAME VERSION' syntaxDavid Golden2009-10-061-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for setting the $VERSION of a namespace when the namespace is declared with 'package'. It eliminates the need for 'our $VERSION = ...' and similar constructs. E.g. package Foo::Bar 1.23; # $Foo::Bar::VERSION == 1.23 There are several advantages to this: * VERSION is parsed in *exactly* the same way as 'use NAME VERSION' * $VERSION is set at compile time * Eliminates '$VERSION = ...' and 'eval $VERSION' clutter * As it requires VERSION to be a numeric literal or v-string literal, it can be statically parsed by toolchain modules without 'eval' the way MM->parse_version does for '$VERSION = ...' * Alpha versions with underscores do not need to be quoted; static parsing will preserve the underscore, but during compilation, Perl will remove underscores as it does for all numeric literals During development of this, there was discussion on #corehackers and elsewhere that this should also allow other metadata to be set such as "status" (stable/alpha) or "author/authority". On reflection, those metadata are not very well defined yet and likely should never be encoded into Perl core parsing so they can be freely changed in the future. (They could perhaps be achieved via a comment on the same line as 'package NAME VERSION'.) Version numbers, however, already have a very specific definition and use defined in the core through 'use NAME VERSION'. This patch merely provides appropriate symmetry for setting $VERSION with the exact same parsing and semantics as 'use'. It does not break old code with only 'package NAME', but code that uses 'package NAME VERSION' will need to be restricted to perl 5.11.X. This is analogous to the change to open() from two-args to three-args. Users requiring the latest Perl will benefit, and perhaps N years from now it will become standard practice when Perl 5.12 is targeted the way that 5.6 is today. The patch does not prevent 'package NAME VERSION' from being used multiple times for the same package with different version numbers, but nothing prevents $VERSION from being modified arbitrarily at runtime, either, so I see no urgen reason to add limitations or warnings so long as Perl uses a global $VERSION variable for package version numbers. I am posting this patch to the p5p list for discussion and review. If there seems to be general assent (or lack of dissent), I will go ahead and commit the patch to blead.
* Fix building MAD with C++ - a MAD_PV of "" is illegal, as it will be free()d.Nicholas Clark2009-09-241-1/+1
|
* Make MAD understand the "..." operatorRafael Garcia-Suarez2009-08-261-0/+1
|
* Allow when to be used as a statement modifierVincent Pit2009-03-281-0/+2
|
* PATCH: Large omnibus patch to clean up the JRRT quotesTom Christiansen2008-11-021-1/+5
| | | | | | Message-ID: <25940.1225611819@chthon> Date: Sun, 02 Nov 2008 01:43:39 -0600 p4raw-id: //depot/perl@34698
* Update copyright years.Nicholas Clark2008-10-251-0/+1
| | | p4raw-id: //depot/perl@34585
* Add ..., !!!, and ??? operatorschromatic2008-05-181-2/+7
| | | | | Message-Id: <200805101252.11961.chromatic@wgz.org> p4raw-id: //depot/perl@33858
* Fix the line-number-in-elsif longstanding bug.Rafael Garcia-Suarez2008-04-181-1/+1
| | | | | | | | | | This patch does two things : - newSTATEOP now nullifies the state op it just created if OPf_SPECIAL is passed to it in flags - the parser now inserts a nullified stateop in the expression block of an elsif p4raw-id: //depot/perl@33710
* Eliminate use of Nullop in the core code. Dual life uses remain.Nicholas Clark2008-02-101-32/+32
| | | p4raw-id: //depot/perl@33269
* Remove remaining C<Nullch>s and C<Nullsv>sNicholas Clark2007-10-061-3/+3
| | | p4raw-id: //depot/perl@32054
* [perl #43425] local $[: fix scoping during parser error handling.Dave Mitchell2007-07-161-9/+7
| | | | | | | | | Change 22306# inadvertently made 'local $[' statement-scoped rather than block-scoped; so revert that change and add a different fix. The problem was to ensure that the savestack got popped correctly while popping errored tokens. We how record the current value of PL_savestack_ix with each pushed parser state. p4raw-id: //depot/perl@31615
* fix some (mostly MAD) compiler warningsDave Mitchell2007-05-131-16/+18
| | | p4raw-id: //depot/perl@31209
* Give the 'local' declarator a new key, such that 'local our'Gerard Goossen2007-05-121-1/+1
| | | | | | | | declaration don't have multiple 'd' keys. Subject: [PATCH] mad: different key for the locale declarator Message-Id: <20070508171125.GI17043@ostwald> p4raw-id: //depot/perl@31208
* move PL_in_my and PL_in_my_stash into the PL_parser structDave Mitchell2007-05-121-1/+1
| | | p4raw-id: //depot/perl@31203
* move PL_rsfp_filters into the parser structDave Mitchell2007-05-121-1/+2
| | | p4raw-id: //depot/perl@31200
* move PL_expect and PL_copline into the PL_parser structureDave Mitchell2007-05-041-21/+21
| | | p4raw-id: //depot/perl@31134
* Silence the g++ warnings "right-hand operand of comma has no effect"Nicholas Clark2007-04-101-6/+6
| | | p4raw-id: //depot/perl@30900
* fix MAD compilation of C-style for loopGerard Goossen2007-03-221-1/+1
| | | | | | Subject: [PATCH] MAD C-style for loop Message-Id: <20070321181852.GD31539@ostwald> p4raw-id: //depot/perl@30676
* Patch by Gerard Goossen to add madprops to "require" opcodeRafael Garcia-Suarez2007-03-151-4/+8
| | | p4raw-id: //depot/perl@30599