summaryrefslogtreecommitdiff
path: root/perly.tab
Commit message (Collapse)AuthorAgeFilesLines
...
* Avoid braces warning in regen_perly.plDavid Mitchell2012-06-131-1/+1
|
* make qr/(?{})/ behave with closuresDavid Mitchell2012-06-131-537/+540
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this commit, qr// with a literal (compile-time) code block will Do the Right Thing as regards closures and the scope of lexical vars; in particular, the following now creates three regexes that match 1, 2 and 3: for my $i (0..2) { push @r, qr/^(??{$i})$/; } "1" =~ $r[1]; # matches Previously, $i would be evaluated as undef in all 3 patterns. This is achieved by wrapping the compilation of the pattern within a new anonymous CV, which is then attached to the pattern. At run-time pp_qr() clones the CV as well as copying the REGEXP; and when the code block is executed, it does so using the pad of the cloned CV. Which makes everything come out all right in the wash. The CV is stored in a new field of the REGEXP, called qr_anoncv. Note that run-time qr//s are still not fixed, e.g. qr/$foo(?{...})/; nor is it yet fixed where the qr// is embedded within another pattern: continuing with the code example from above, my $i = 99; "1" =~ $r[1]; # bare qr: matches: correct! "X99" =~ /X$r[1]/; # embedded qr: matches: whoops, it's still seeing the wrong $i
* remove deprecated qw-as-parens behaviourZefram2012-05-251-373/+366
|
* Label UTF8 cleanupBrian Fraser2012-03-251-22/+22
| | | | | This meant changing LABEL's definition in perly.y, so most of this commit is actually from the regened files.
* Bump several file copyright datesSteffen Schwigon2012-01-191-2/+2
| | | | | | | 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-791/+810
| | | | | | | | 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.
* Add an optional third argument to open_new(), to invoke read_only_top() with.Nicholas Clark2011-05-191-1/+1
| | | | Merge together many calls to open_new() and read_only_top().
* Rename safer_open() to open_new(), and eliminate the first parameter.Nicholas Clark2011-05-191-1/+1
| | | | Update the SHA256s where necessary in the generated files.
* Store the SHA-256 of the source in files generated by regen_perly.plNicholas Clark2011-01-231-1/+4
| | | | | | | bison isn't available everywhere, so we can't simply re-run regen_perly.pl to verify that perly.{act,h,tab} are up to date. So instead store the SHA-256 of the input files, and extend t/porting/regen.t to check that the input files haven't been changed subsequently.
* Output "read only" editor blocks from regen_perly.plNicholas Clark2011-01-231-0/+8
| | | | | | | | | Use safer_open() and read_only_bottom_close_and_rename() from regen_lib.pl Consistently use 3 argument open and lexical file handles. A side effect of this change is that the generated files are no longer made read-only on disk - if this is desirable, then probably better to change regen_lib.pl so that all generated files are made read-only.
* permit labels to be stackedZefram2010-12-131-689/+810
| | | | | 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-2/+2
| | | | | | | 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-784/+780
| | | | | | New API functions parse_fullexpr(), parse_listexpr(), parse_termexpr(), and parse_arithexpr(), to parse an expression at various precedence levels.
* make regen_perlyFather Chrysostomos2010-11-111-18/+18
|
* refactor GRAMPROG grammar slightlyZefram2010-11-071-743/+747
| | | | | 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-19/+19
| | | | | | 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-785/+775
| | | | | 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-19/+19
| | | | | | | | | 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-676/+669
| | | | | | | | | | | | | | | | | | | | 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-655/+654
| | | | | | | | 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-775/+782
| | | | | 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-634/+627
| | | | | 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-644/+635
| | | | | | | | | | | | | 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-22/+22
| | | | | | 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-798/+813
| | | | | New API function parse_stmtseq() parses a sequence of statements, up to closing brace or EOF.
* make qw(...) first-class syntaxZefram2010-09-081-704/+718
| | | | | | | | | | 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.
* Regenerate headers after last patchRafael Garcia-Suarez2010-09-061-752/+769
|
* remove dead listexprcom production from grammarZefram2010-08-311-342/+329
| | | | | 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-21/+21
| | | | | | 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-14/+14
| | | | | | 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-663/+675
| | | | | | 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.
* Allow arbitrary whitespace between NAME and VERSION in "package NAME ↵Jesse Vincent2010-02-031-1/+1
| | | | | | VERSION;" statements Fixes [perl #72432]
* regen_perly prepping for 5.11.4Ricardo Signes2010-01-191-1/+1
|
* [perl #22977] Bug in format/writeZefram2009-12-151-16/+16
|
* regen generated files changed by the previous patch - facility to plug in ↵Jesse Vincent2009-11-051-746/+749
| | | | syntax triggered by keywords
* make regen; make regen_perlyJesse Vincent2009-10-201-1/+1
|
* Restore MAD handling of package statementsRafael Garcia-Suarez2009-10-081-14/+14
| | | | | Since the version seems unused by MAD in "use", do the same for "package"...
* Add 'package NAME VERSION' syntaxDavid Golden2009-10-061-566/+566
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* make regen; make regen_perlyJesse Vincent2009-10-021-1/+1
| | | | | | | The newer bison generated perly.h with a GPL3 or later license statement rather than the previous GPL2 statement. Our use appears to be subject to the exception that's immediately below that, so this shouldn't matter.
* Make MAD understand the "..." operatorRafael Garcia-Suarez2009-08-261-5/+5
|
* Allow when to be used as a statement modifierVincent Pit2009-03-281-657/+662
|
* Add ..., !!!, and ??? operatorschromatic2008-05-181-632/+640
| | | | | Message-Id: <200805101252.11961.chromatic@wgz.org> p4raw-id: //depot/perl@33858
* [perl #43425] local $[: fix scoping during parser error handling.Dave Mitchell2007-07-161-723/+714
| | | | | | | | | 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/+16
| | | p4raw-id: //depot/perl@31209
* move PL_rsfp_filters into the parser structDave Mitchell2007-05-121-14/+14
| | | p4raw-id: //depot/perl@31200
* Patch by Gerard Goossen to add madprops to "require" opcodeRafael Garcia-Suarez2007-03-151-5/+5
| | | p4raw-id: //depot/perl@30599
* Fix leaks in label strings allocation in COPsRafael Garcia-Suarez2006-12-201-18/+18
| | | p4raw-id: //depot/perl@29601
* remove extraneous declaration prom perly.tabDave Mitchell2006-12-161-1/+0
| | | p4raw-id: //depot/perl@29564