Giter Club home page Giter Club logo

expandable's People

Contributors

obi1kenobi avatar scrabsha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

expandable's Issues

Support the whole Rust grammar

expandable works quite well, but it only supports a very reduced subset of Rust.

In order to make it complete, we have to write a state machine that accepts every syntactically valid Rust code (and nothing more!). This is currently done thanks to a 260 line-long invocation of the generate_grammar macro. This is very painful to understand and update properly. It certainly won't scale to the whole Rust grammar.

The other solution is to write a parser for Rust in a dsl that is then turned into a state machine by a custom compiler, and replace the generate_grammar stuff with this shiny state machine. This means more code to maintain, document and test, but this would make future development so much easier that it's worth it.

Here are the different steps we will follow:

  • #30 Write a compiler that generates the state machine. The output language will be plain Rust code that is (hopefully) debuggable. The input language won't be fancy:
    • No variables.
    • No nested expressions, except blocks (needed for conditions).
    • Very limited conditionals (just a bunch of builtins).
    • Primitive loops (is it really needed?).
    • No function return value.
  • #34 Modify the state machine handling logic so that it converges on transitions instead of converging on states. This will allow us to accommodate cases where the generated state machine is suboptimal and pushes unnecessary values onto its stack (otherwise, this would result in never-ending checking).
  • #35 Write a parser of the Rust language in the DSL. We could take inspiration from the Ferrocene Language Specifications, the The Rust Reference, rustc_parse or even syn.
  • #36 Get rid of the generate_grammar state machine, use the generated state machine instead.
  • #39 Add support for the || operator in grammar_gen
  • Add the whole Rust grammar to grammar.rs
  • Write custom tests.
  • Set up a solid test harness. For instance, we could parse code from crates.io, or the rustc test suite. weird_exprs.rs may be a challenging one :D
  • ...
  • Profit!

It could be interesting to benchmark the parser, but I don't consider it an important item.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.