cltk
This is a port of the Ruby Language Toolkit to the Crystal Programming Language.
CLTK (like RLTK) is: a collection of classes and methods designed to help programmers work with languages in an easy to use and straightforward manner. This toolkit provides the following features:
- Lexer generator
- Parser generator
- AST node baseclass
- Class for representing context free grammars
In addition, CLTK includes several ready-made lexers and parsers. As well as a Serialization Mechanism that translates an finalized parser back into crystal syntax to compile it without having to be finalized again at startup. (see exp_lang_repl for a usage example).
To see what works have a look at the specs or run them with:
$ crystal spec
The code of the Parser is very hackey at the moment and was translated merely by try and error with the testsuite (RED
> GREEN
but so far no refactoring). The AST Implementation is a complete rewrite. The LLVM Bindings (cltk/cg
) has not been ported. Instead crystals own LLVM Bindings were used in examples/kazoo/chapter 8/kcontractor.cr
Usage
See the example languages (and their specs) WIP :
- interpreted language EXP_LANG (
examples/exp_lang
) - kazoo (
examples/kazoo/chapter 8
) with LLVM IR generation - brainfuck (
examples/brainfuck
) - json_parser (
examples/json_parser
) example of a linter / xml converter
Contributing
- Fork it ( https://github.com/ziprandom/cltk/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- ziprandom - creator of the port, maintainer