Haskell parser for the Ruby 2.6 Language. Project structure is loosely based https://github.com/erikd/language-javascript, lexer is based on https://github.com/bjpop/language-python and parser is based on https://github.com/whitequark/parser.
$ stack build
$ stack test --file-watch --fast
$ happy src/Parser.y -dai
AST Nodes naming is the same as whitequark/parser's, with the following notable exceptions and changes:
CamelCase
is used instead ofsnake_case
. E.g.:(Str "foo")
instead ofs(:str, "foo")
(BackRef "$&")
instead ofs(:back_ref, :$&)
- Special
__
variables have being completly renamed and are not being processed:File
instead of__FILE__
Encoding
instead of__ENCODING__
Line
instead of__LINE__
- Varargs are replaced by lists:
(Begin [RInt 4, RInt 5])
instead ofs(:begin, s(:int, 4), s(:int, 5))
- Ruby datatypes are prefixed with an in order to avoid collisions. E.g.:
RInt
instead ofint
RFloat
instead offloat
- Parser acts as if run with
Parser::Builders::Default.emit_procarg0 = false
and thus makes no distinction betweenf {|a|}
andf{|a,|}
since making such a distinction for only blocks with a single parameter seems odd.
This project is just an on-going progress:
- ✔️ Grammar is mostly finished
- ❎ Lexer is incompletle
- ❎ Tree builder and AST is mostly unimplemented
- ❎ Happy build times are slow which is cumbersome for development, I should check bjpop/language-python#41. On the meanwhile, just comment grammar rules that are not being developed.