-
Notifications
You must be signed in to change notification settings - Fork 7
/
README
58 lines (45 loc) · 1.51 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
+ What is tinylex?
A tiny lexical analyser generator
+ How to implement?
I refer to Allen Holub's book 'Compiler design in C'
and write it by myself.
+ Format of the input file
(see test/colour.l for example, which is a C syntax higlighter):
%{
< code block for definition or macro >
%}
< Macro Definition: macroname macrotext >
< e.g: digit [0-9] >
< recursive macro definition is not allowed.>
%%
< Rules: regularexp action string >
< e.g: {digit}+ printf("%d", yytext); >
< only one-line action string is allowed. >
%%
< code block for main function >
+ Usage:
compile:
# make
[generate tinylex and egrep_like ]
# ./tinylex -p lex.yy.part.c {source script}.l -o {generated ouput}.c
test:
# make test
[see the output information]
debug:
# make debug
[generate many debug programes, such as nfa]
# ./nfa test/common_test.l
[output NFAS information according to
common_test.l script (regular expresion for testing) ]
+ TODO:
1. bugfix:
using `grep -C 2 -n FIXME *.c` to get bug information
2. make tinylex compatible with flex/lex.
(Tinylex is only subset of flex/lex now.
And many auxiliary functions or flags aren't supported,
such as yywrap/yymore/yyrestart)
3. support multi-line accept action string
(Maybe I need a internal C parser.)
4. support recursive macro definition
+ Author:
Xiaochen Wang <[email protected]>