X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=tiger%2Fsrc%2Flib%2Ftiger%2Ftiger_lexer.mll;h=359366f2ae9ba4197e5dddf592e7b23a79bb8bcd;hb=c7598faf75e8c27dcf2019dac47e56841af1f569;hp=c19eabfdcd1bb8aa38acd7c3f49c22103912b065;hpb=dd245b34bf95b84454067b025f72b206be84fa50;p=tiger.ml.git diff --git a/tiger/src/lib/tiger/tiger_lexer.mll b/tiger/src/lib/tiger/tiger_lexer.mll index c19eabf..359366f 100644 --- a/tiger/src/lib/tiger/tiger_lexer.mll +++ b/tiger/src/lib/tiger/tiger_lexer.mll @@ -1,5 +1,5 @@ { - open Tiger_parser.Token + open Tiger_parser let comment_level = ref 0 let string_buf = Buffer.create 100 @@ -10,9 +10,7 @@ let num = ['0'-'9'] let newline = '\n' | '\r' | "\n\r" rule token = parse - | eof { - EOF - } + | eof {EOF} (* Track line number *) | newline { @@ -83,7 +81,7 @@ rule token = parse | "type" -> TYPE | "var" -> VAR | "while" -> WHILE - | _ -> ID id + | _ -> (ID id) } and string_literal = parse (* Keep escaped quote marks as part of the string literal *) @@ -104,10 +102,8 @@ and string_literal = parse string_literal lexbuf } and comment = parse - | eof { - (* TODO: Error: unterminated comment? or we don't care? *) - EOF - } + (* TODO: Error: unterminated comment? or we don't care? *) + | eof {EOF} (* Track line number *) | newline {