Skip to content

rewrite the parser #940

Closed
Closed

Description

@k1ngmang

There's no point in dragging a dependency like antlr into a project. It's easier to write a regular recursive parser or a Pratt parser. Not only will the project get rid of an obviously unnecessary dependency, but such code will also be very easy to read and write.

Activity

  1. emil14 commented on Nov 13, 2025

    @emil14
    Collaborator

    @k1ngmang

    There're two reasons why I think it's better to stick with current solution:

    1. It's declarative to have grammar file as source of true for parsing;
    2. Language is not yet stable including it's syntax and parser-generators allow to move faster at MVP stage.

    I agree though that manual parser allows to get rid of dependency and perhaps improve performance (it's good to have some parser benchmarks first, perhaps)

  2. k1ngmang commented on Nov 13, 2025

    @k1ngmang
    ContributorAuthor

    @emil14

    It's not just about performance, but also about maintainability. While a formalized grammar can be useful in many places (for example, for plugins in popular editors like IntelliJ IDEA), editing a regular recursive parser is still easier.

    You mentioned that the language's syntax is unstable, which means that describing complex syntactic constructs will be a real pain in the ass in the future, so it's better to take care of this in advance. For IDE, we can describe a regular BNF grammar.

  3. emil14 commented on Nov 13, 2025

    @emil14
    Collaborator

    It's not just about performance, but also about maintainability. While a formalized grammar can be useful in many places (...), editing a regular recursive parser is still easier.

    Easier how?

    • Grammar is not longer source of true -> you have to manually keep it in sync with the parser source code -> it's possible to get them out of sync (not possible at the moment)
    • You change grammar -> make antlr -> update listener/visitor (you even get compile errors after codegen)

    language's syntax is unstable, which means that describing complex syntactic constructs will be a real pain in the ass in the future, so it's better to take care of this in advance

    Yes and to me it's the reason to have declarative grammar!


    Not directly answers your message but related to the topic.

    I don't honestly think Neva syntax will get more complicated than now, I'm actually thinking about removing existing features (see #935 in case of curiousity)

  4. added
    optimisation
    idea
    refactoring
    p2
    on Nov 14, 2025
  5. locked and limited conversation to collaborators on Nov 26, 2025
  6. converted this issue into a discussion #945 on Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ideaoptimisationp2refactoring

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions