Skip to content

Implement negation#30

Open
ip1981 wants to merge 1 commit intomozilla:mainfrom
ip1981:ip1981/negate
Open

Implement negation#30
ip1981 wants to merge 1 commit intomozilla:mainfrom
ip1981:ip1981/negate

Conversation

@ip1981
Copy link

@ip1981 ip1981 commented May 25, 2023

No description provided.

Copy link
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ip1981 Thank you so much for fixing this!

It's been on my list for so long, but I haven't had the brain space to learn how lalrpop works.

I've added a couple of comments below: the biggest thing to fix is the precedence ordering, and naming.

I think you'll likely end up making an UnOp60 (or similarly named rule).

Once you get operator precedence squared away, re-request a review from me!

Many thanks, again!

"^" => OpCode::Exponent,
};

Op60: UnOpCode = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: given this is at Expr70 level, to follow the rest of the code, could we name this Op80?

Expr70: Box<Expression> = {
<subject: Expr70> <index: Index> => Box::new(Expression::IndexOperation{subject, index}),
<subject: Expr70> "." <ident: Identifier> => Box::new(Expression::DotOperation{subject, ident}),
<operation: Op60> <right: Expr80> => Box::new(Expression::UnaryOperation { operation, right }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should . and [ bind tighter than !? Playground with the jexl-js.

I couldn't see a test, and I'm not familiar enough with lalrpop know. Please could you add tests verifying the following work:

foo == [false]
!foo[0] == true
foo == { "bar": false }
!foo.bar  == true

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've updated my patch fixing priorities, naming, adding the tests you suggested.

@fgalan
Copy link

fgalan commented May 14, 2024

I would be great if this PR could be merge to implement the ! operator that original JavaScript JEXL implementation provides :)

@fgalan
Copy link

fgalan commented May 17, 2024

I would be great if this PR could be merge to implement the ! operator that original JavaScript JEXL implementation provides :)

...and also it seems it would help to make the unary minus to work (issue #27)!

Signed-off-by: Igor Pashev <pashev.igor@gmail.com>
Copy link

@jgrund jgrund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be reviewed again / merged?

@jgrund
Copy link

jgrund commented May 27, 2025

Ping

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.

4 participants