cedar-policy / cedar-go

Golang implementation of the Cedar Policy Language
Apache License 2.0
83 stars 9 forks source link

Fix parsing of reserved keywords #33

Closed patjakdev closed 2 months ago

patjakdev commented 2 months ago

Issue #, if available: None

Description of changes:

This PR modifies the Cedar tokenizer to properly reserve the set of reserved keywords from the Cedar spec. In addition, it resolves a parsing ambiguity for the Primary production, which requires a lookahead to determine whether it will be a VAR, Entity, or ExtFun.

patjakdev commented 2 months ago

See further discussion of this PR on the StrongDM fork

kjamieson-sdm commented 2 months ago

It looks like this forbids the use of reserved keywords in annotation keys, which the Rust implementation specifically allows (see https://github.com/cedar-policy/cedar/pull/634). Are we concerned about that difference in behaviour?

patjakdev commented 2 months ago

It looks like this forbids the use of reserved keywords in annotation keys, which the Rust implementation specifically allows (see cedar-policy/cedar#634). Are we concerned about that difference in behaviour?

Good catch @kjamieson-sdm. I was basing this on the documented grammar.

I'll add a test specifically for this case.