Giter Club home page Giter Club logo

Comments (5)

irmen avatar irmen commented on June 8, 2024

"a little writeup" 😄

from prog8.

meisl avatar meisl commented on June 8, 2024

Oh well...

from prog8.

irmen avatar irmen commented on June 8, 2024

@meisl a little history: I read a few articles by Federico Tomassetti about antlr and kotlin ast's, I think one of them was https://tomassetti.me/parse-tree-abstract-syntax-tree/ and that put me on the way of the 'toAst()' extension methods. They've since stuck as the mechanism to get the kotlin ast classes from the antlr syntax tree.

Finally, there's this https://github.com/Strumenta/antlr-kotlin/ but it's still experimental . It could perhaps be used to remove the antlr java parser code and replace it with kotlin parser code directly -- but we still want to convert the antlr syntax tree to our own specialized ast classes.

from prog8.

irmen avatar irmen commented on June 8, 2024
  • IStringEncoding is no longer part of the CompilerAst (actually, in 7.2, it has now been moved to a new module containing a bunch of compiler related interfaces that are shared over other modules. CompilerAst is NOT among those btw)
  • the containing module is not needed as global state to get the position from- these are extracted from the stream that the parser is reading from

from prog8.

irmen avatar irmen commented on June 8, 2024

while the complex "compiler Ast" as discussed above is still generated from the antlr parser, there is now also a new lightweight "codeAst" that is meant to be used in the codegenerator (this still has to be built)
So the idea is that the compilerAst is going to be internal to the compiler and optimizer phases and is no longer needed/visible in the codegenerators.

The new simpler Ast can be constructed incrementally by adding child nodes to incomplete parent nodes.

The compiler right now and the optimizers have way too much dependencies on the old Ast classes still, so replacing that by the new Ast completely is a bit too much for now, but maybe this can be done in the future to simplify things there as well.

from prog8.

Related Issues (20)

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.