-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tlexer.mll
69 lines (62 loc) · 1.76 KB
/
tlexer.mll
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
(**************************************************************************)
(* *)
(* Menhir *)
(* *)
(* François Pottier, INRIA Rocquencourt *)
(* Yann Régis-Gianas, PPS, Université Paris Diderot *)
(* *)
(* Copyright 2005-2008 Institut National de Recherche en Informatique *)
(* et en Automatique. All rights reserved. This file is distributed *)
(* under the terms of the Q Public License version 1.0, with the change *)
(* described in file LICENSE. *)
(* *)
(**************************************************************************)
{
open Tparser
exception Error of string
}
(* OBS: When adding new token, don't forget to add it in reg expr in tellstory.ml *)
rule line = parse
| ([^'\n']* '\n') as line
{ line }
| eof
{ "" }
and token = parse
| [' ' '\t']
{ token lexbuf }
| '\n'
{ EOL }
| '\\'
{ BACKSLASH }
| '$'
{ DECKSIGN }
| '@'
{ GRAPHSIGN }
| '%'
{ DICESIGN }
| '#'
{ MACROSIGN }
| '.'
{ RECORDDOT }
| ':'
{ INPUTSIGN }
| '+'
{ PLUS }
| '-'
{ MINUS }
(*
| '"'
{ QUOTE }
*)
| '|'
{ BARLINE }
| ['0'-'9']+ as i
{ INT (int_of_string i) }
| ['a'-'z' 'A'-'Z' '_' '0'-'9']+ as i
{ WORD i }
| ['"'] [^ '"']+ ['"'] as i
{ QUOTE i }
| eof
{ EOL}
| _
{ raise (Error (Printf.sprintf "unexpected character: %s\n" (Lexing.lexeme lexbuf))) }