Add the tiger source code bundle from the book site
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
915660c8a7
commit
33d8bac511
87 changed files with 3252 additions and 0 deletions
18
tiger/chap2/tiger.lex
Normal file
18
tiger/chap2/tiger.lex
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
type pos = int
|
||||
type lexresult = Tokens.token
|
||||
|
||||
val lineNum = ErrorMsg.lineNum
|
||||
val linePos = ErrorMsg.linePos
|
||||
fun err(p1,p2) = ErrorMsg.error p1
|
||||
|
||||
fun eof() = let val pos = hd(!linePos) in Tokens.EOF(pos,pos) end
|
||||
|
||||
|
||||
%%
|
||||
%%
|
||||
\n => (lineNum := !lineNum+1; linePos := yypos :: !linePos; continue());
|
||||
"," => (Tokens.COMMA(yypos,yypos+1));
|
||||
var => (Tokens.VAR(yypos,yypos+3));
|
||||
"123" => (Tokens.INT(123,yypos,yypos+3));
|
||||
. => (ErrorMsg.error yypos ("illegal character " ^ yytext); continue());
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue