-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSyntax.sml
99 lines (87 loc) · 2.75 KB
/
Syntax.sml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
signature Syntax =
sig
type repr
eqtype str
structure ExpParser : ProtoParser
where type repr = repr
structure TeXPrinter : ReprPrinter
where type repr = repr
structure UTF8Printer : ReprPrinter
where type repr = repr
val repr_parser : string -> repr
val repr_parser_ : repr Parser.parser
end
functor Syntax
(type repr
eqtype str
val grammar : string
structure Induction : Induction
where type repr = repr
and type str = str
structure Deconstructor : Deconstructor
where type repr = Induction.repr
structure Constructor : Constructor
where type repr = Induction.repr
) :> Syntax
where type repr = repr
and type str = str =
struct
open Induction
type repr = repr
type str = str
structure ExpParser =
ProtoParser
(type repr = repr
val grammar = TextFile.read grammar
val start = "TOP"
val terminals = TerminalParsers.parser
val cache:repr Parser.cachet = ref Parser.Empty
structure Induction : Induction
where type repr = repr = Induction
structure Deconstructor : Deconstructor
where type repr = repr = Deconstructor
structure Constructor : Constructor
where type repr = repr = Constructor
) :> ProtoParser
where type repr = repr
val printer = ExpParser.printer
structure UTF8 =
UTF8String
(type repr = repr
type str = str
structure Induction : Induction = Induction
) :> Constructor
where type repr = repr
structure TeX =
TeXString
(type repr = repr
type str = str
structure Induction : Induction = Induction
) :> Constructor
where type repr = repr
structure UTF8Printer =
ReprPrinter
(type repr = repr
val printer = printer
structure Induction : Induction = Induction
structure Deconstructor : Deconstructor = Deconstructor
structure Constructor : Constructor = UTF8
) :> ReprPrinter
where type repr = repr
structure TeXPrinter =
ReprPrinter
(type repr = repr
val printer = printer
structure Induction : Induction = Induction
structure Deconstructor : Deconstructor = Deconstructor
structure Constructor : Constructor = TeX
) :> ReprPrinter
where type repr = repr
fun repr_parser s =
let val rs = ExpParser.parser (s^";")
in case rs
of [(r,s)] => r
| _ => raise Fail ("Syntax error")
end
val repr_parser_ = ExpParser.parser_
end