Code Monkey home page Code Monkey logo

wenyan-ast's Introduction

Wenyan Compiler

TODO

  • Tokenize
  • Parsing
  • Importing
  • Macro
  • Better error messaging
  • Render
  • Examples & Stdlib testing
  • Romanize
  • Tree Shaking
  • Execute for Viewer

wenyan-ast's People

Contributors

antfu avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

forkyard sparta-9

wenyan-ast's Issues

New parser for wenyan-lang

This is a rewrite of wenyan-lang parser, with AST and source map support.

Note this is very working in progress. You will definitely face some glitches and bugs.

You can try it online: https://wyo.netlify.com

Features

  • Written in Typescript, tokens and AST are well-typed.

  • Source location supported

Screen Recording 2020-02-728 at 3 50 21 PM

  • Better error handling

Screen Shot 2020-02-28 at 3 56 29 PM

  • Macro expanding, importing, tokenizing finished in a single turn - Should be faster

  • Tree shaking will be very straightforward to implement

Progress

  • Tooling setup
  • Tokenize
  • 🚧Parse (Some of the syntax is not supported yet,try..catch for example)
  • Speed Optimize
  • Tree-shaking
  • Back-compatible api

About the "drifting" answers

I am glad to tell you the overhaul now compiles most of the scripts correctly(the basic examples, draw_trees). :)

However, while I am doing compatibility testing, I found out this line in 算經

https://github.com/antfu/wenyan-overhaul/blob/87d52352b372d70d88f128144b269e3aed612e80/packages/stdlib/lib/%E7%AE%97%E7%B6%93.wy#L46

In the current compiler, it will compile to

    const _ans28 =  + 1;
    const _ans29 = ;
    const _ans30 = ;
    const _ans31 = (_ans29)(_ans30);
    const _ans32 = 造表列(_ans28)(_ans31);

I would say it make sense in some aspect, but it's hard to read and understand without having good knowledge about the compiler internal mechanisms. Which I think should not be advised.

I would suggest changing it to this

https://github.com/antfu/wenyan-overhaul/blob/d01080a3e7d92a78d930d8eadae36902227d5cc5/packages/stdlib/lib/%E7%AE%97%E7%B6%93.wy#L103

The new compiler does not maintain a "drifting" answers list (i forget what's its name in the code), instead, it makes the relationship of variables static during AST generation. (and there is no need for as well). So I am wondering if we should drop this "non-intuitive" mechanism in the new compiler? Or if there is any reason to have this mechanism please let me know. :)

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.