mirror of
https://github.com/c-cube/sidekick.git
synced 2025-12-09 04:35:35 -05:00
22 lines
768 B
OCaml
22 lines
768 B
OCaml
|
|
{
|
|
type token = EOF | ZERO | LIT of int | D | R | I
|
|
}
|
|
|
|
let number = ['1' - '9'] ['0' - '9']*
|
|
|
|
rule token = parse
|
|
| eof { EOF }
|
|
| "c" { comment lexbuf }
|
|
| [' ' '\t' '\r'] { token lexbuf }
|
|
| "d" { D }
|
|
| "r" { R }
|
|
| "i" { I }
|
|
| '\n' { Lexing.new_line lexbuf; token lexbuf }
|
|
| '0' { ZERO }
|
|
| '-'? number { LIT (int_of_string (Lexing.lexeme lexbuf)) }
|
|
| _ { Error.errorf "dimacs.lexer: unexpected char `%s`" (Lexing.lexeme lexbuf) }
|
|
|
|
and comment = parse
|
|
| '\n' { Lexing.new_line lexbuf; token lexbuf }
|
|
| [^'\n'] { comment lexbuf }
|