Skip to content

Instantly share code, notes, and snippets.

@thosakwe
Created February 6, 2018 19:06
Show Gist options
  • Save thosakwe/1d0a1279fbaef68e6c6b59267d0d843f to your computer and use it in GitHub Desktop.
Save thosakwe/1d0a1279fbaef68e6c6b59267d0d843f to your computer and use it in GitHub Desktop.
Dynamic parser generator system???
## 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.
# 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