Skip to content

Commit

Permalink
correct whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsterling committed Aug 10, 2017
1 parent 731712d commit 3f59795
Show file tree
Hide file tree
Showing 38 changed files with 3,310 additions and 3,310 deletions.
164 changes: 82 additions & 82 deletions automaton.sml
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

2 changes: 1 addition & 1 deletion cmyacc-hs.mlb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lexer-hs.sml
parser-hs.sml

glue-hs.sml
go-hs.sml
go-hs.sml
2 changes: 1 addition & 1 deletion cmyacc.mlb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ lexer.sml
parser.sml

glue.sml
go.sml
go.sml
24 changes: 12 additions & 12 deletions codegen-hs.sml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ structure CodegenHs
then l is a big-endian list of chars representing n
|l| = stateSize
l' = map Char.ord l
and
and
return l'
*)
fun intToChars size n =
let
val l =
map
val l =
map
(fn w => Word.toInt w)
(wordToBytelist (Word.fromInt n) [])
in
Expand Down Expand Up @@ -85,7 +85,7 @@ structure CodegenHs
))

val monadic = D.member options (Symbol.fromValue "monadic")

val (terminalOrdinals, terminalCount) =
D.foldl
(fn (terminal, _, (ordinals, count)) =>
Expand Down Expand Up @@ -127,7 +127,7 @@ structure CodegenHs

val majorLimit =
Int.max (stateCount, Vector.length rules + 1)

val (majorSize, adjust) =
if majorLimit <= 127 then
(1, 128)
Expand Down Expand Up @@ -221,7 +221,7 @@ structure CodegenHs
else
();
write " Control.Exception.SomeException,\n\n {- type arguments -}\n";

appSeparated
(fn typeName =>
(
Expand Down Expand Up @@ -249,7 +249,7 @@ structure CodegenHs
write " ";
write (Symbol.toValue actionName);
write " :: ";

(* By construction, we have a complete, no-duplicate sequence from 1 to some n. *)
app
(fn (_, tp) =>
Expand All @@ -258,7 +258,7 @@ structure CodegenHs
write " -> "
))
dom';

write (Symbol.toValue cod)
end)
(fn () => write ",\n")
Expand Down Expand Up @@ -350,7 +350,7 @@ structure CodegenHs
else
();
write " Control.Exception.SomeException";

app
(fn typeName =>
(
Expand All @@ -375,7 +375,7 @@ structure CodegenHs
write ",\n";
write (Symbol.toValue actionName);
write " :: ";

(* By construction, we have a complete, no-duplicate sequence from 1 to some n. *)
app
(fn (_, tp) =>
Expand All @@ -384,7 +384,7 @@ structure CodegenHs
write " -> "
))
dom';

write (Symbol.toValue cod)
end)
actions;
Expand Down Expand Up @@ -588,7 +588,7 @@ structure CodegenHs
raise (Fail "invariant"))
0
args;

Array.app
(fn n =>
(
Expand Down
18 changes: 9 additions & 9 deletions codegen.sig
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
Loading

0 comments on commit 3f59795

Please sign in to comment.