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

Parsing of name.{ in SelectedValue #75

Open
glen-84 opened this issue Dec 17, 2024 · 3 comments
Open

Parsing of name.{ in SelectedValue #75

glen-84 opened this issue Dec 17, 2024 · 3 comments

Comments

@glen-84
Copy link
Contributor

glen-84 commented Dec 17, 2024

SelectedValue ::
    Path
    SelectedObjectValue
    Path . SelectedObjectValue
    SelectedValue | SelectedValue

A SelectedValue of, for example, field.{ a } will begin parsing as a Path due to the Name token. After the period in a PathSegment, another PathSegment is required, but the next token will instead be a LeftBrace token.

Expected a Name-token, but found a LeftBrace-token.

Should we perform a negative lookahead when parsing a PathSegment, so that the period isn't consumed when followed by a left brace, or is there another solution here?

@benjie
Copy link
Member

benjie commented Dec 17, 2024

Also don't do SelectedValue | SelectedValue which has both left- and right- recursion; you should split them up so only one recurses:

SelectedValue ::

- SelectedValue | SelectedValueEntry
- `|`? SelectedValueEntry

SelectedValueEntry ::

- Path [lookahead != `.`]
- Path . SelectedObjectValue
- SelectedObjectValue

@benjie
Copy link
Member

benjie commented Dec 17, 2024

Also it looks like your markdown has suffered from prettier autoformatting reflecting mistakes in your original formatting - it's important that the definition (Foo ::) and the definition list are separated by a blank line, otherwise they get treated by markdown as a paragraph.

Path :: - < TypeName > . PathSegment - PathSegment
PathSegment :: - FieldName - FieldName . PathSegment - FieldName < TypeName > .
PathSegment
FieldName :: - Name
TypeName :: - Name

@glen-84
Copy link
Contributor Author

glen-84 commented Dec 17, 2024

That's fixed in #63. 🙂

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

No branches or pull requests

2 participants