Giter Club home page Giter Club logo

crispy-parakeet's Introduction

Description:

a port of the rowan calc example using lalrpop & logos as the parser/lexer. The concrete syntax tree produced is fairly clunky still.

This repo is a demonstration of the current state, and will probably be deleted or moved elsewhere eventually.

What works

However it does successfully produce a syntax tree, passing the builder through the parser and getting a syntax tree out. The way this works is the grammar gets passed a &mut Builder which the grammar does not return, thus the mutable reference goes out of scope, the caller then has exclusive ownership.

branches

there are branches for sorbus, rowan, and the rowan thread_local_cache branch. The resulting tree ends up something like a reverse polish notation.

AST Clunkiness

  • Doesn't include whitespace for no good reason other than i'm too lazy.
  • The top-down builder API isn't a natural fit for the bottom up parser
  • We end up with Oper nodes of 2 or 3 children In a stack-like semantics rather than consistent 3 nodes like the rowan calc example.
- Root
  - Oper
    - Oper
      - "2" Number
      - "3" Number
      - "*" Mul
    - "1" Number
    - "+" Add
  - Oper
    - "4" Number
    - "-" Sub

TODO ...

Needs to test out a branch based on the rowan pr #63

Other thoughts

Sorbus has a finish_node_at, function perhaps this could be more useful for constructing bottom-up however I haven't thought through it.

It seems like an appropriate API might be something like:

reparent_current_node_onto(self, kind: SyntaxKind), which would take the current node and make it a child of the new node of kind.

crispy-parakeet's People

Contributors

ratmice avatar

Watchers

 avatar  avatar

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.