Comments (7)
"a little writeup" 😄
from prog8.
Oh well...
from prog8.
@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.
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.
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.
At least all code generator backends now are no longer dependent on the "compiler Ast" but instead use that simpler "code Ast" instead. I'm finalizing this on the "codegen-on-new-ast" branch. All code generators share the same interface and only see that new ast and the symbol table.
from prog8.
This has been an interesting collection of observations, but they're no longer relevant to the current state of how the compiler works.
At least not for the "public" version of the Ast that is being used in the code generators.
(the internal compiler Ast is still mostly what it was, maybe it will be moved onto the new Ast one day too but that is way too much refactoring work for now)
from prog8.
Related Issues (20)
- Newline is significant when it shouldn't be HOT 1
- Don't do that! [about the idea to remove drive num from diskio routines] HOT 7
- Array of Structs HOT 4
- filenames with non-ASCII characters don't get loaded by the compiler on Windows while in UTF-8 mode HOT 1
- @(variable) to work for uword as well as ubyte HOT 4
- Prog8 generates ASM that will not build HOT 3
- parse error: no viable alternative at input 'not in' Where as, this does not: HOT 3
- How to convert uword to str? HOT 3
- Docs: List all available @varflags/tags HOT 4
- Problem with string.find(...) HOT 2
- Support for new encodings HOT 8
- known problems in version 10.3
- compiler crash when using call builtin HOT 6
- string.find is not working HOT 6
- Incorrect 6502 asm generated with indexing a uword pointer using array syntax HOT 1
- Compilation broken with new Kotlin versions HOT 1
- windows build fails on line endings HOT 1
- floats.atan2() wrong results
- vera CTRL not properly reset in line drawing code
- for 'raw' outputs, syslib is sometimes not imported
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prog8.