summaryrefslogtreecommitdiff
path: root/perly.tab
Commit message (Collapse)AuthorAgeFilesLines
* fix incorrect vi filetype declarations in generated filesLukas Mai2023-03-241-1/+1
| | | | | Vim's filetype declarations are case sensitive. The correct types for Perl, C, and Pod are perl, c, and pod, respectively.
* Have start_subparse() call class_prepare_method_parse() if CVf_IsMETHODPaul "LeoNerd" Evans2023-03-061-766/+764
|
* Have newATTRSUB() call class_wrap_method_body() if CVf_IsMETHODPaul "LeoNerd" Evans2023-03-061-43/+42
|
* Allow :isa in class declaration without a blockArne Johannessen2023-03-021-681/+681
| | | | | | | | | Using class attributes in the unit class syntax was a syntax error. This change makes the following two lines equivalent: class B :isa(A) ; class B :isa(A) { } Addresses GH issue #20888.
* perly.* - update generated files to include file type in modelineYves Orton2023-02-191-13/+14
| | | | | | | | This is a companion patch to the previous one, it is generated with a slightly more modern Bison which produces better indented output, and puts parens around constant defines and other minor changes. It is recommended to view this patch with the -w option to skip most of the the "non change" changes it contains.
* Fix a bunch of memory leaks in feature 'class'Paul "LeoNerd" Evans2023-02-171-6/+6
| | | | | | | | | | | * Free the attrlist OP fragment when applying class or field attribute * Free the OP_PADxV ops we only use to get the pad index out for fieldvar declarations * Add a refcount to the `struct padname_fieldinfo` to keep track of its capture in inner closures so it can be freed at the right time * Free the class-related fields out of HvAUX * Free the actual ObjectFIELDS() array when destroying an object instance * Dup fieldinfo->paramname at sv_dup() time / free it at free time
* Field :param attributes, //= and ||= default assignmentsPaul "LeoNerd" Evans2023-02-101-1/+1
|
* Parse an optional attribute list for fields; currently no attributes are definedPaul "LeoNerd" Evans2023-02-101-791/+793
|
* Accept field VAR = EXPR on field varsPaul "LeoNerd" Evans2023-02-101-707/+707
| | | | | Allows non-constant expressions with side effects. Evaluated during the constructor of each instance.
* Initial attack at parsing attribute syntax for class blocks; though no attrs ↵Paul "LeoNerd" Evans2023-02-101-595/+601
| | | | are yet defined
* Initial attack at basic 'class' featurePaul "LeoNerd" Evans2023-02-101-1024/+1084
| | | | | | | | | | | | | Adds a new experimental warning, feature, keywords and enough parsing to implement basic classes with an empty `new` constructor method. Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted Creates a new OP_METHSTART opcode to perform method setup Define an aux flag to remark which stashes are classes Basic implementation of fields. Basic anonymous methods.
* Define five new operator precedence levelsPaul "LeoNerd" Evans2022-12-161-922/+962
| | | | | | | | | | | | Assignment operators (`==`) were missing, as were both the logical and the low-precedence shortcutting OR and AND operators (`&&`, `||`, `and`, `or`) Also renumbered them around somewhat to even out the spacing. This is fine during a development cycle. Also renamed the tokenizer/parser symbol names from "PLUG*OP" to "PLUGIN_*_OP" for better readability.
* Token type `pval` should be a void * pointerPaul "LeoNerd" Evans2022-12-141-1/+1
| | | | | | | | | | The `pval` field of the token type union is currently only used in one place; storing the result of the infix operator plugin. Its use here stores a structure pointer, not a string. The union should define this field as a `void *` and not a `char *`. In addition we should not attempt to debug print it as a string because its value is not valid as one.
* Define a PL_infix_plugin hook, of a similar style to PL_keyword_pluginPaul "LeoNerd" Evans2022-12-081-845/+915
| | | | | | | | | Runs for identifier-named custom infix operators and sequences of non-identifier symbol characters. Defines multiple precedence levels for custom infix operators that fit alongside exponentiation, multiplication, addition, or relational comparision operators, as well as a "high" and "low" at either end.
* Recognise `//=` and `||=` syntax in signature parameter defaultsPaul "LeoNerd" Evans2022-11-261-34/+33
| | | | | | These create parameters where the default expression is assigned whenever the caller did not pass a defined (or true) value. I.e. both if it is missing, or is present but undef (or false).
* perly.y - add a diag_listed_as for UnimplementedYves Orton2022-10-311-26/+26
| | | | | | | | | | | In 1557e6c32831defe4b25a924a88baf5f5e7bcbdd we added a perldiag entry for 'Unimplemented', which was good. But in theory the message should have been picked up by the diagnostics tests when it was introduced. However, this error message is not constructed in the normal way, and the string was not identified as a message. This adds the appropriate comment in the appropirate place so that the diagnostics test will notice it should it change in the future. This necessitated a make perly_regen.
* perly.* - update perly files with more recent bisonYves Orton2022-10-311-12/+13
| | | | | | | | | | | I want to modify perly with a comment. But that would leave us with output files that are out of date in comparison with the input files. My bison is later than the last used for perl, so running it without my patch makes large changes. Therefore I have separated the change into two pieces, the first just updates everything using my more modern bison, the second runs bison again with the change I actually made. This is the first of the pair, nothing changes here except that which bison changed.
* Better handling of builtin CV attributesPaul "LeoNerd" Evans2022-10-251-22/+22
| | | | | | | | | | | The previous code would handle subroutine attributes directly against `PL_compcv` as a side-effect of merely parsing the syntax in `yyl_colon()`, an unlikely place for anyone to find it. This complicates the way the parser works. The new structure creates a new function to apply all the builtin attributes out of an attribute list to any given CV, and invokes it from the parser at a slightly better time.
* Add comments to perly.y to explain token orderingPaul "LeoNerd" Evans2022-10-021-28/+28
| | | | | Explains why KW_PACKAGE and KW_USE_or_NO appear to have the package name and version barewords in the wrong order.
* Rename token types for keywords to add KW_... prefixPaul "LeoNerd" Evans2022-07-021-848/+796
| | | | | | | | | | | Some of the token types represent simple keywords; some of them do not. It's easier to read and work out what's going on if all the simple keyword ones have a common prefix; `KW_...` in this case. Additionally I've renamed the four `sub`-related keywords to have a bit more structure to them. Also added comments.
* Rename some grammar rules/tokens to avoid 'method'Paul "LeoNerd" Evans2022-06-281-22/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | These token names are shared between perl.y and toke.c, to communicate on the nature of various tokens parsed from perl source. The name FUNCMETH used to refer to a method call with possible arguments ->NAME(...) whereas METHOD referred to one without even the parens ->NAME These names are a little confusing, and most importantly, METHOD was in the way of my adding a new `method` keyword as part of the upcoming work on 'use feature "class"'. As such, this simple rename moves them out of the way and makes them slightly more consistent and easier to read/remember, by calling them METHCALL and METHCALL0. This commit also renames the `method` grammar rule to `methodname`, for similar reasons. As all of these names are entirely internal to the tokenizer/parser, there is not expected to be any upstream CPAN incompatibility, or other issues, caused by these renames.
* A better error message for `try {} catch {}` missing its (VAR)Paul "LeoNerd" Evans2022-06-131-1076/+830
| | | | | | | | | | | | As suggested in https://github.com/Perl/perl5/issues/19811, this now outputs the message: $ ./perl -Mexperimental=try try { A() } catch { B() } catch block requires a (VAR) at - line 2, near "catch {" Execution of - aborted due to compilation errors.
* for my ($x) ...: fix handling of degenerate 1-varDavid Mitchell2022-04-161-74/+317
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new for my ($x,$y,...) (...) { ... } syntax has a couple of problems in the degenerate case of a single variable: for my ($x) (...) { ... } First, the loop variable is marked as lexical, but not as a variable to be introduced. So it behaves roughly as if written like: { my $x; for $x (...) { ... } } I can't think of any user-visible runtime change in behaviour this bug causes, so I haven't included a test for it. Second, it was being incorrectly deparsed as for $x (...) { ... } (i.e. without the 'my'). This commit fixes both of these issues. The basic problem is that the parser, in the case of multiple vars, passes a list subtree of PADSVs as the 'sv' argument of Perl_newFOROP, but in the case of a single var, passes a single PADSV op instead. This single PADSV doesn't have the LVINTRO flag set, so is indistinguishable from plain my $x; for $x .... This commit makes the parser set the OPf_PARENS flag on the lone PADSV to signal to newFOROP() that it's a degenerate 1-var list, and newFOROP() sets the OPf_PARENS flag on the ENTERITER op to signal to the deparser that this is "for my (...)" syntax, even if it only has a single var.
* Don't emit experimental::signatures warning (closes #13681)Paul "LeoNerd" Evans2022-02-201-20/+20
|
* Use `optexpr` in anonymous to reduce number of symbolsBranislav Zahradník2022-02-051-668/+627
|
* Unify optional rulesBranislav Zahradník2022-02-051-18/+18
| | | | | - start with `opt` (renamed `siglistornull`) - employ bison's default rule whenever possible
* Introduce rule `empty` returning NULLBranislav Zahradník2022-02-051-727/+755
| | | | to save few keystrokes ...
* Gather all MY variants into single ruleBranislav Zahradník2022-02-051-61/+61
|
* Set the CvSIGNATURE flag on signatured subsPaul "LeoNerd" Evans2022-01-311-20/+20
|
* Implement and test try/catch/finally syntaxPaul "LeoNerd" Evans2022-01-201-1147/+919
|
* for my ($foo,,, $bar) { ... } should parse as ($foo, $bar)Nicholas Clark2021-10-151-1/+1
| | | | | Multiple commas between the lexicals in the list shouldn't change the parsing.
* Implement n-at-a-time for loops.Nicholas Clark2021-10-151-750/+776
| | | | | | | | | For example, this now works: for my ($key, $value) (%hash) { ... } Only for scalars declared with my as a list in the for loop statement. As many as you want (unless you want more than 4294967296).
* fix line number of try blockDavid Mitchell2021-09-041-98/+338
| | | | | | | | | | | | | | | | | | Each 'try' block has a nextstate COP prepended to it. Currently this cop has the line number of the line following the end of the try block. Fix it so that it has the line number of the line containing the 'try' keyword instead. This is achieved using the same technique as other block-introducing keywords like 'while': set the .ival of the 'try' token returned by the lexer to the current line number, then set PL_parser->copline back to that value after parsing the block but before creating the COP. This issue was showing up as a failure in cd t; ./TEST -deparse op/try.t since that test script is line-number sensitive.
* Create `defer` syntax and `OP_PUSHDEFER` opcodePaul "LeoNerd" Evans2021-08-251-832/+846
| | | | | | | | | | | | | | | Adds syntax `defer { BLOCK }` to create a deferred block; code that is deferred until the scope exits. This syntax is guarded by use feature 'defer'; Adds a new opcode, `OP_PUSHDEFER`, which is a LOGOP whose `op_other` field gives the start of an optree to be deferred until scope exit. That op pointer will be stored on the save stack and invoked as part of scope unwind. Included is support for `B::Deparse` to deparse the optree back into syntax.
* Add a newTRYCATCHOP(); migrate the custom code out of perly.y into itPaul "LeoNerd" Evans2021-02-141-26/+26
|
* Initial attempt at feature 'try'Paul "LeoNerd" Evans2021-02-041-848/+860
| | | | | | | | | * Add feature, experimental warning, keyword * Basic parsing * Basic implementation as optree fragment See also https://github.com/Perl/perl5/issues/18504
* Use explicit %emptyBranislav Zahradník2020-12-271-10/+10
|
* Cleanup remnants of 'KEY_err' removalBranislav Zahradník2020-12-271-776/+774
| | | | f23102e2d6 removed DOROP token (KEY_err) but related grammar remained
* Distinguish C- and perly- literals - PERLY_DOLLARBranislav Zahradník2020-12-271-816/+792
|
* Distinguish C- and perly- literals - PERLY_SLASHBranislav Zahradník2020-12-271-757/+771
|
* Distinguish C- and perly- literals - PERLY_STARBranislav Zahradník2020-12-271-793/+807
|
* Distinguish C- and perly- literals - PERLY_PAREN_CLOSEBranislav Zahradník2020-12-271-38/+40
|
* Distinguish C- and perly- literals - PERLY_PAREN_OPENBranislav Zahradník2020-12-271-14/+14
|
* Distinguish C- and perly- literals - PERLY_PERCENT_SIGNBranislav Zahradník2020-12-271-644/+638
|
* Distinguish C- and perly- literals - PERLY_SNAILBranislav Zahradník2020-12-271-626/+579
|
* Distinguish C- and perly- literals - PERLY_PLUSBranislav Zahradník2020-12-271-677/+679
|
* Distinguish C- and perly- literals - PERLY_MINUSBranislav Zahradník2020-12-271-657/+657
|
* Distinguish C- and perly- literals - PERLY_QUESTION_MARKBranislav Zahradník2020-12-271-45/+47
|
* Distinguish C- and perly- literals - PERLY_COLONBranislav Zahradník2020-12-271-33/+33
|
* Distinguish C- and perly- literals - PERLY_TILDEBranislav Zahradník2020-12-271-41/+41
|