-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglexer.mll
More file actions
42 lines (33 loc) · 835 Bytes
/
glexer.mll
File metadata and controls
42 lines (33 loc) · 835 Bytes
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
(* Lexer for .grp 2021/10/28 *)
{
open Gparser
}
let space = [' ' '\t' '\n' '\r']
let eol = ['\n' '\r']
let digit = ['0'-'9']
let comment = "//"
rule token = parse
| '(' { LPAREN }
| ')' { RPAREN }
| ',' { COMMA }
| "directed" { DIRECTED }
| "undirected" { UNDIRECTED }
| digit*
{ NUM (int_of_string (Lexing.lexeme lexbuf)) }
| eof { EOF }
| space+ { token lexbuf }
| comment [^ '\n' '\r']* eol { token lexbuf }
| _
{
let message = Printf.sprintf
"unknown token %s near characters %d-%d"
(Lexing.lexeme lexbuf)
(Lexing.lexeme_start lexbuf)
(Lexing.lexeme_end lexbuf)
in
failwith message
}
and comment = parse
| eol { token lexbuf }
| eof { EOF }
| _ { comment lexbuf }