-
Notifications
You must be signed in to change notification settings - Fork 0
/
symbol.mli
47 lines (33 loc) · 1.1 KB
/
symbol.mli
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
(** Tokens supported by the lexer. *)
module Token : sig
(** Token type. *)
type t = Number of float
| Left (* "(" *)
| Right (* ")" *)
| Fact (* "!" *)
| Cos (* "cos" *)
| Mult (* "*" *)
| Plus (* "+" *)
| Minus (* "-" *)
| EOF (* End-of-line *)
(** Format token. *)
val to_string : t -> string
end
(** Terminal symbols - alias for tokens. *)
module Terminal = Token
(** Nonterminal symbols of the grammar driving the parser. *)
module Nonterminal : sig
type t = E' (* starting symbol in "augmented" grammar *)
| E (* Expression *)
| T (* Term *)
| F (* Factor *)
| CA (* Cosine Argument *)
| FA (* Factorial Argument *)
| U (* Unsigned Number *)
(** Set of terminal symbols that can follow the given nonterminal. *)
val follow : t -> Terminal.t list
(** Format nontermnial. *)
val to_string : t -> string
end
(** General symbol of the grammar - either a terminal or a nonterminal. *)
type t = Term of Terminal.t | Nonterm of Nonterminal.t