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

[RFC007] Migrate the parser to the new AST #2083

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Commits on Nov 21, 2024

  1. Improve record representation in the new AST

    Instead of elaborating piecewise definitions (such as `{foo.bar = 1,
    foo.baz = 2}`) directly at the parsing stage, this commit makes the new
    AST closer to the source language by making record a list of field
    definition, where the field "name" can be a sequence of identifiers and
    strings. This representation is used internally by the parser; we now
    make it the default in the AST, such that the migration of the parser
    won't have to do this elaboration at all. The elaboration is offloaded
    to the conversion to `RichTerm`, which happens in the `ast::compat`
    module.
    
    This makes the AST closer to the source language.
    
    The first motivation is that it'll be better for the LSP, where some
    open issues on the tracker are caused by the inability to trace what the
    LSP get back to the original piecewise definitions.
    
    The second reason is that we can't actually elaborate a piecewise
    definition while staying in the new AST correctly as of today: the new
    AST only has one record variant, which is recursive by default, but this
    doesn't match the way recursion and scoping work for piecewise
    definition. For example, `{foo.bar = 1, baz.foo = foo + 1}` works fine
    in today's Nickel (evaluate to `{foo = {bar = 1}, baz {foo = 2}}`), but
    if we elaborate it in the new AST naively, we'll get an infinite
    recursion: `{foo = {bar = 1}, baz = {foo = foo + 1}}`.
    
    Mailine Nickel currently uses a non recursive `Record` for that, but we
    don't want to introduce such "runtime dictionary" in the new AST as they
    can't be expressed in the source language. Instead, we rather keep
    record as defined piecewise and will do further elaboration when needed,
    during typechecking, future compilation, or in the meantime when
    converting the new AST representation to mainline Nickel.
    yannham committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    7d86368 View commit details
    Browse the repository at this point in the history
  2. Switch to the new AST repr for parser - part I

    First stab at making the parser compatible with the new AST
    representation (`bytecode::ast::Ast`). This is a heavy
    refactoring which required to update most of `parser::uniterm` and
    `parser::utils` as well as `grammar.lalrpop`.
    
    The current version is far from compiling; fixing compiler errors is
    planned in follow-up work.
    yannham committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    bc7387d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4f08a58 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    de5e9f4 View commit details
    Browse the repository at this point in the history
  5. Remove bytecode-experimental feature

    As we move toward a bytecode compiler and a bytecode virtual machine, we
    are replacing the left part of the pipeline with the new AST
    representation.
    
    The bytecode module was previously gated by an experimental feature,
    thea idea being that this feature would enable the whole bytcode
    compiler pipeline. However, for now, we only have a new AST
    representation, and it's being used in the mainline Nickel parser (and
    soon, in the typechecker, etc.). Thus we need access to the new AST
    representation by default, and it doesn't make much sense to gate it
    behind a feature.
    
    We'll reintroduce the feature once we have a prototype compiler and a
    bytecode virtual machine, when it will then make sense to use the
    feature to toggle between the legacy tree-walking interpreter and the
    new bytecode compiler.
    yannham committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    426a11d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    3af6e10 View commit details
    Browse the repository at this point in the history
  7. Revert to the previous handling of last fields (might need conflict r…

    …esolution for RepeatSep1)
    yannham committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    e751489 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2324c35 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    6b0426d View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    77db0bf View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    4059bca View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    f7d0403 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    1f7dbe1 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    751165d View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    2259027 View commit details
    Browse the repository at this point in the history
  16. Fix swapped seal/unseal

    yannham committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    d6e3573 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    4fe9aea View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    a394c35 View commit details
    Browse the repository at this point in the history