mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-12-05 15:20:50 +00:00
feat: Support file as argument and better error message
This commit is contained in:
+8
-5
@@ -4,9 +4,8 @@
|
||||
exception Error of char
|
||||
}
|
||||
|
||||
let line_comment = "//" [^ '\n']*
|
||||
let block_comment = "/*" [^'.']* "*/"
|
||||
let comment = line_comment | block_comment
|
||||
let line_comment = "//" [^'.']*'\n'
|
||||
let block_comment = "/*" [^'.']* "*/"
|
||||
|
||||
let letter = ['a'-'z' 'A'-'Z']
|
||||
let digit = ['0'-'9']
|
||||
@@ -20,8 +19,12 @@ let char = "'" [^'.'] "'"
|
||||
let string = '"' [^'.']* '"'
|
||||
|
||||
rule token = parse
|
||||
| [' ' '\t'] | comment { token lexbuf }
|
||||
| ['\n'] { Lexing.new_line lexbuf; token lexbuf }
|
||||
| ' ' | '\t' { token lexbuf }
|
||||
| '\n' | line_comment { Lexing.new_line lexbuf; token lexbuf }
|
||||
| block_comment as comment {
|
||||
String.iter (fun c -> if c = '\n' then Lexing.new_line lexbuf) comment;
|
||||
token lexbuf
|
||||
}
|
||||
|
||||
| '+' { PLUS }
|
||||
| '-' { MINUS }
|
||||
|
||||
Reference in New Issue
Block a user