1 # nitcc, a parser and lexer generator for Nit
3 nitcc is a simple LR generator for Nit programs.
4 It features a small subset of the functionalities of [SableCC] 3 and 4.
6 [SableCC]: http://sablecc.org
10 Have a valid compiler in `bin/`
11 Just run `make` in the `contrib/nitcc/` directory
19 nitcc generates a bunches of control files, a lexer, a parser, and a tester.
21 To compile and run the tester:
23 nitg file_test_parser.nit
24 ./file_test_parser an_input_file_to_parse
26 ## Examples and regression tests
28 The sub-directory `examples/` contains simple grammars and interpretors.
30 The sub-directory `tests/` contains regression tests.
32 ## Features (aka TODO list)
34 [X] command line tool (`nitcc`)
35 [X] Grammar syntax of SableCC4 (with pieces of SableCC3)
37 [X] Generates a SLR parser
38 [ ] Generates a LALR parser
39 [X] Generates classes for the AST and utils
41 For the tool (and the code)
44 [X] bootstrap itself (see `nitcc.sablecc`)
46 For the lexer (and regexp, NFA en DFA)
49 [X] interval of characters and subtraction of characters
50 [X] implicit priorities (by inclusion of languages)
52 [X] Shortest and Longest (but dummy semantic without lookahead)
53 [X] efficient implementation of intervals
56 For the parser (and grammar and LR)
58 [X] Modifiers (`?`, `*`, `+`)
65 [X] simple transformation
68 For the AST (generated classes, utils and their API)
70 [X] Common runtime-library `nitcc_runtime.nit`
71 [X] Terminal nodes; see `NToken`.
72 [X] Heterogeneous non-terminal nodes: named fields; see `NProd`.
73 [X] Homogeneous nodes for lists (`+` and `*`); see `Nodes`.
74 [X] Visitor design pattern; see `Visitor`.
75 [X] Syntactic and lexical errors; see `Nerror`.
76 [X] positions of tokens in the input stream; see `Position`
78 ## BUGS and limitations
80 * Limited error checking; bad grammars can produce uncompilable, or worse buggy, nit code.
81 * The SLR automaton is not very expressive; do not except to parse big and complex language like Nit or Java.
82 * The generated Nit code is inefficient and large; do not except to parse big and complex language like Nit or Java.
84 * Advanced features of SableCC4 are not planed.