Created
February 6, 2018 19:06
-
-
Save thosakwe/1d0a1279fbaef68e6c6b59267d0d843f to your computer and use it in GitHub Desktop.
Dynamic parser generator system???
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Concept | |
It sucks to do the following: | |
* Write an AST | |
* Write a scanner | |
* Write a parser | |
* Test the parser | |
* Write language documentation | |
So... Why not do it automatically? | |
## Why not ANTLR? | |
ANTLR is nice, but error support will never be perfect, and it requires learning unfamiliar, inflexible syntax. | |
This also only reduces the process to two steps: coming up with the language, and then writing the specification. | |
## So... What then? | |
This is somewhat resemblant of JetBrains MPS, in which you write the AST, and just the AST. | |
You feed the build system language samples and AST mappings, and it automatically reverse-engineers the language structure. | |
Once that's in place, you're home free. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code samples | |
''' | |
class Foo { | |
void doIt(int a, String b) async { | |
retuen 24 * 3; | |
} | |
} | |
''' | |
# Mappings | |
{ | |
'class': decl('Class') { | |
members [ | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment