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

Lexing of spaces breaks attribute parsing #43

Closed
techieAgnostic opened this issue Jul 24, 2023 · 0 comments · Fixed by #47
Closed

Lexing of spaces breaks attribute parsing #43

techieAgnostic opened this issue Jul 24, 2023 · 0 comments · Fixed by #47
Labels
bug Something isn't working parser Related to Ezno's syntax parser, AST definitions and output

Comments

@techieAgnostic
Copy link
Contributor

When evaluating an expression that has an attribute, the current lexer in the parser-fixes2 branch allows matching spaces as part of the tag name. This prevents the Lexing State from moving to lexing the attributes, instead giving an error when it reaches the = character.

Example: running ezno ast-explorer ast and using the expression <div className="test"></div>
Output:

error: 
  ┌─ INPUT:1:2
  │
1 │ <div className="test"></div>
  │  ^ Invalid character '=' in JSX tag

When removing the match on spaces here it allows the lexer to continue onto the attribute lexing state, giving the following output for the same example:

JSXRoot(
    Element(
        JSXElement {
            tag_name: "div",
            attributes: [
                Static(
                    "className",
                    "test",
                    5..21,
                ),
            ],
            children: Children(
                [],
            ),
            expression_id: ExpressionId(1),
            position: 0..28,
        },
    ),
)

I have a fork with the changes made to the parser-fixes2 branch here, but wanted to double check that there wasn't a reason to be lexing spaces as part of the tag name first.

Thank you :)

@kaleidawave kaleidawave added bug Something isn't working parser Related to Ezno's syntax parser, AST definitions and output labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Related to Ezno's syntax parser, AST definitions and output
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants