nitcc: add README
[nit.git] / contrib / nitcc / README.md
1 # nitcc, a parser and lexer generator for Nit
2
3 nitcc is a simple LALR generator for Nit programs.
4 It features a small subset of the functionalities of [SableCC] 3 and 4.
5
6   [SableCC]: http://sablecc.org
7
8 ## How to compile
9
10 Have a valid compiler in `bin/`
11 Just run `make` in the `contrib/nitcc/` directory
12
13 ## How to run
14
15 Usage:
16
17    nitcc file.sablecc
18
19 Generate a bunches of control files, a lexer, a parser, and a tester.
20
21 ## Examples and regression tests
22
23 The sub-directory `examples/` contains simple grammars and interpretors.
24
25 The sub-directory `t/` contains regression tests.
26
27 ## Features (aka TODO list)
28
29 [X] command line tool (`nitcc`)
30 [X] Grammar syntax of SableCC4 (with pieces of SableCC3)
31 [X] Generates a Lexer
32 [X] Generates a LALR parser
33 [X] Generates classes for the AST and utils
34
35 For the tool (and the code)
36
37 [X] usable
38 [X] bootstrap itself (see `nitcc.sablecc`)
39
40 For the lexer (and regexp, NFA en DFA)
41
42 [X] Any
43 [X] interval of characters and subtraction of characters
44 [X] implicit priorities (by inclusion of languages)
45 [ ] Shortest
46 [ ] DFA minimization
47 [ ] efficient implementation of intervals
48
49 For the parser (and grammar and LR)
50
51 [X] Modifiers (`?`, `*`, `+`)
52 [X] Ignored
53 [ ] Rejected
54 [ ] Opportunistic
55 [ ] Precedence
56 [ ] Separator
57 [ ] Dangling
58 [X] simple transformation
59 [x] simple inlining
60
61 For the AST (generated classes, utils and their API)
62
63 [X] Common runtime-library `nitcc_runtime.nit`
64 [X] Terminal nodes; see `NToken`.
65 [X] Heterogeneous non-terminal nodes: named fields; see `NProd`.
66 [X] Homogeneous nodes for lists (`+` and `*`); see `Nodes`.
67 [X] Visitor design pattern; see `Visitor`.
68 [X] Syntactic and lexical errors; see `Nerror`.
69 [X] positions of tokens in the input stream; see `Position`
70
71 ## BUGS and limitations
72
73 * Limited error checking; bad grammars can produce uncompilable, or worse buggy, nit code.
74 * The LALR automaton is buggy; do not except to parse big and complex language like Nit or Java.
75 * The generated Nit code is inefficient and large; do not except to parse big and complex language like Nit or Java.
76 * No unicode.
77 * Advanced features of SableCC4 are not planed.
78