Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle asymmetric precedence #53

Merged
merged 13 commits into from
May 27, 2020
Merged

Handle asymmetric precedence #53

merged 13 commits into from
May 27, 2020

Conversation

vickenty
Copy link
Collaborator

Parse code like this:
(sort $a, $b + sort $c, $d)
($a, $b = open $b, $c = $d)

LHS of expressions can not contain named operators (in this case they
bind to the rightmost parameter), but RHS can.

Fixes #48
Fixes #52

Parse code like this:
`(sort $a, $b + sort $c, $d)`
`($a, $b = open $b, $c = $d)`

LHS of expressions can not contain named operators (in this case they
bind to the rightmost parameter), but RHS can.

Fixes #48
Fixes #52
@vickenty vickenty changed the title Handle assymetric precedence Handle asymmetric precedence May 25, 2020
@xsawyerx
Copy link
Owner

You are an f'ing genius, @vickenty!

The test with c::d() failed because we didn't account
for the non-q-like function names being the entire subroutine name
(like "c()") or having a package separator (like "c::d()").

This is now fixed! \o/
While fixing up tests, I found that we don't tell the difference between
Ident used for classes and ones used for subroutine names.

They're mostly similar, but the following is different:

1. Foo::->bar()  # method call, works
2. Foo->bar()    # same, ambiguous to perl, but not to guacamole
3. Foo::bar()    # Function call, Foo class, bar function name
4. Foo::bar::()  # Error!

But because we use Ident for all of these, #1 and #4 are getting confused.

We can fix it. It's not a top priority.
@xsawyerx
Copy link
Owner

xsawyerx commented May 25, 2020

I pushed a few fixes for tests and some rules. Added a few more. Here's the current state:

t/Statements/Block.t ...................................... ok
t/Statements/Condition.t .................................. ok
t/Statements/Ellipsis.t ................................... ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordChmod.t ... ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordOpen.t .... ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordSplice.t .. ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordSplit.t ... ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordStat.t .... ok
t/Statements/Expressions/OpKeywordExpr/OpKeywordSub.t ..... ok
t/Statements/Expressions/Value/ArrowDerefVariable.t ....... ok
t/Statements/Expressions/Value/Literal.t .................. 1/?
#  [...] Fails with "-4", "44.4", and "-44.4"
t/Statements/Expressions/Value/Literal.t .................. 7/? # Looks like you failed 3 tests of 16.
t/Statements/Expressions/Value/Literal.t .................. Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/16 subtests
t/Statements/Expressions/Value/NonLiteral/SubCall.t ....... ok
t/Statements/Expressions/Value/QLikeValue.t ............... ok
t/Statements/Expressions/arrow.t .......................... ok
t/Statements/Expressions/basic.t .......................... ok
t/Statements/Expressions/fold.t ........................... 1/?
t/Statements/Expressions/variable.t ....................... ok
t/Statements/LoopStatement.t .............................. ok
t/Statements/PackageStatement.t ........................... ok
t/Statements/PhaseStatements.t ............................ ok
t/Statements/RequireStatement.t ........................... ok
t/Statements/SubStatement.t ............................... ok
t/Statements/UseNoStatement.t ............................. ok
t/Statements/WhileStatement.t ............................. ok

Test Summary Report
-------------------
t/Statements/Expressions/Value/Literal.t                (Wstat: 768 Tests: 16 Failed: 3)
  Failed tests:  1, 4-5
  Non-zero exit status: 3
Files=23, Tests=413, 18 wallclock secs ( 0.14 usr  0.03 sys + 17.62 cusr  0.77 csys = 18.56 CPU)
Result: FAIL

All of our relevant tests pass!

"It's just a string that some underlying C libraries numify to a value
representing infinity." -- Ikegami @ PerlMonks
@xsawyerx
Copy link
Owner

(The failing tests above were moved to TODO after I created tickets for each. They're not urgent.)

@xsawyerx
Copy link
Owner

@vickenty, should we merge? I want to move forward with additional fixes.

Vickenty Fesunov added 3 commits May 27, 2020 13:39
This fixes precedence issues for assignment named operators, to
correctly parse code like this:

`($a = goto $b = $c)`
`($a + goto $d + $e)`
Give separate names to arguments of all named operators, so future
fixes to precedence can be done without updating all definitions
Include marpa's progress if we failed to parse something
@vickenty vickenty marked this pull request as ready for review May 27, 2020 11:43
@xsawyerx xsawyerx merged commit 032ce9a into master May 27, 2020
@xsawyerx xsawyerx deleted the splice branch May 27, 2020 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

List keywords can be used in a list Cannot assign from keywords
2 participants