forked from RobertHarper/cmyacc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
731712d
commit 3f59795
Showing
38 changed files
with
3,310 additions
and
3,310 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,82 @@ | ||
|
||
structure SymbolOrdered = SymbolOrderedFun (structure Symbol = Symbol) | ||
structure SymbolHashable = SymbolHashableFun (structure Symbol = Symbol) | ||
structure SymbolDict = SplayDict (structure Key = SymbolOrdered) | ||
structure SymbolSet = SplaySet (structure Elem = SymbolOrdered) | ||
|
||
structure Automaton = | ||
struct | ||
|
||
type precedence = int option | ||
type label = Syntax.label | ||
|
||
(* Ideally, this should be a record. *) | ||
type rule = | ||
int (* rule number *) | ||
* | ||
int (* rule number within nonterminal *) | ||
* | ||
Symbol.symbol (* lhs *) | ||
* | ||
Symbol.symbol list (* rhs *) | ||
* | ||
label option list (* arguments *) | ||
* | ||
bool (* sole argument: | ||
True iff the arguments contain exactly one label | ||
and that label is 1. | ||
*) | ||
* | ||
Symbol.symbol (* action *) | ||
* | ||
precedence (* precedence *) | ||
* | ||
bool ref (* reduced? *) | ||
|
||
datatype action = | ||
Shift of int | ||
| Reduce of int | ||
|
||
type item = | ||
int (* rule number *) | ||
* | ||
int (* number of symbols read *) | ||
* | ||
Symbol.symbol list (* remaining symbols *) | ||
|
||
datatype conflict = | ||
NoConflict | ||
| Resolved | ||
| Conflict | ||
|
||
type state = | ||
(action list * conflict) SymbolDict.dict (* action table: each list nonempty, ordered in decreasing priority *) | ||
* | ||
int SymbolDict.dict (* goto table *) | ||
* | ||
(item * SymbolSet.set) list (* LR(1) items *) | ||
|
||
type automaton = | ||
int (* total states *) | ||
* | ||
state list (* states *) | ||
* | ||
rule Vector.vector (* rules *) | ||
* | ||
Symbol.symbol (* start symbol *) | ||
|
||
type parser = | ||
string SymbolDict.dict (* options *) | ||
* | ||
SymbolSet.set (* type arguments *) | ||
* | ||
(Symbol.symbol option * precedence * bool ref) SymbolDict.dict (* terminals *) | ||
* | ||
(int list * Symbol.symbol * bool ref) SymbolDict.dict (* nonterminals *) | ||
* | ||
(Symbol.symbol * (Syntax.label * Symbol.symbol) list * Symbol.symbol) list (* actions *) | ||
* | ||
automaton (* the automaton *) | ||
|
||
end | ||
|
||
structure SymbolOrdered = SymbolOrderedFun (structure Symbol = Symbol) | ||
structure SymbolHashable = SymbolHashableFun (structure Symbol = Symbol) | ||
structure SymbolDict = SplayDict (structure Key = SymbolOrdered) | ||
structure SymbolSet = SplaySet (structure Elem = SymbolOrdered) | ||
|
||
structure Automaton = | ||
struct | ||
|
||
type precedence = int option | ||
type label = Syntax.label | ||
|
||
(* Ideally, this should be a record. *) | ||
type rule = | ||
int (* rule number *) | ||
* | ||
int (* rule number within nonterminal *) | ||
* | ||
Symbol.symbol (* lhs *) | ||
* | ||
Symbol.symbol list (* rhs *) | ||
* | ||
label option list (* arguments *) | ||
* | ||
bool (* sole argument: | ||
True iff the arguments contain exactly one label | ||
and that label is 1. | ||
*) | ||
* | ||
Symbol.symbol (* action *) | ||
* | ||
precedence (* precedence *) | ||
* | ||
bool ref (* reduced? *) | ||
|
||
datatype action = | ||
Shift of int | ||
| Reduce of int | ||
|
||
type item = | ||
int (* rule number *) | ||
* | ||
int (* number of symbols read *) | ||
* | ||
Symbol.symbol list (* remaining symbols *) | ||
|
||
datatype conflict = | ||
NoConflict | ||
| Resolved | ||
| Conflict | ||
|
||
type state = | ||
(action list * conflict) SymbolDict.dict (* action table: each list nonempty, ordered in decreasing priority *) | ||
* | ||
int SymbolDict.dict (* goto table *) | ||
* | ||
(item * SymbolSet.set) list (* LR(1) items *) | ||
|
||
type automaton = | ||
int (* total states *) | ||
* | ||
state list (* states *) | ||
* | ||
rule Vector.vector (* rules *) | ||
* | ||
Symbol.symbol (* start symbol *) | ||
|
||
type parser = | ||
string SymbolDict.dict (* options *) | ||
* | ||
SymbolSet.set (* type arguments *) | ||
* | ||
(Symbol.symbol option * precedence * bool ref) SymbolDict.dict (* terminals *) | ||
* | ||
(int list * Symbol.symbol * bool ref) SymbolDict.dict (* nonterminals *) | ||
* | ||
(Symbol.symbol * (Syntax.label * Symbol.symbol) list * Symbol.symbol) list (* actions *) | ||
* | ||
automaton (* the automaton *) | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ lexer-hs.sml | |
parser-hs.sml | ||
|
||
glue-hs.sml | ||
go-hs.sml | ||
go-hs.sml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ lexer.sml | |
parser.sml | ||
|
||
glue.sml | ||
go.sml | ||
go.sml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
|
||
signature CODEGEN = | ||
sig | ||
|
||
exception Error | ||
|
||
val writeProgram : string -> Automaton.parser -> unit | ||
|
||
end | ||
|
||
signature CODEGEN = | ||
sig | ||
|
||
exception Error | ||
|
||
val writeProgram : string -> Automaton.parser -> unit | ||
|
||
end |
Oops, something went wrong.