Delete trailing whitespace in mlyacc sources
This commit is contained in:
parent
c126813667
commit
6a5ae1f8e6
|
@ -58,7 +58,7 @@ signature LR_TABLE =
|
|||
| ACCEPT
|
||||
| ERROR
|
||||
type table
|
||||
|
||||
|
||||
val numStates : table -> int
|
||||
val numRules : table -> int
|
||||
val describeActions : table -> state ->
|
||||
|
@ -273,7 +273,7 @@ signature PARSER =
|
|||
|
||||
(* the type of the user-supplied argument to the parser *)
|
||||
type arg
|
||||
|
||||
|
||||
(* type svalue is the type of semantic values for the semantic value
|
||||
stack
|
||||
*)
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
Data Structures:
|
||||
----------------
|
||||
|
||||
|
||||
* The parser:
|
||||
|
||||
The state stack has the type
|
||||
|
@ -195,7 +195,7 @@ local
|
|||
(println "Parse: state stack:";
|
||||
printStack(stack, 0);
|
||||
print(" state="
|
||||
^ showState state
|
||||
^ showState state
|
||||
^ " next="
|
||||
^ showTerminal term
|
||||
^ " action="
|
||||
|
@ -215,7 +215,7 @@ local
|
|||
fixError is called with the arguments of parseStep (lexv,stack,and
|
||||
queue). It returns the lexv, and a new stack and queue adjusted so
|
||||
that the lexv can be parsed *)
|
||||
|
||||
|
||||
val ssParse =
|
||||
fn (table,showTerminal,saction,fixError,arg) =>
|
||||
let val prAction = prAction showTerminal
|
||||
|
@ -415,7 +415,7 @@ fun mkFixError({is_keyword,terms,errtermvalue,
|
|||
tryChange{lex=lexPair,stack=stack,
|
||||
pos=queuePos,orig=[],new=[tokAt(t,l)],
|
||||
leftPos=l,rightPos=l})
|
||||
|
||||
|
||||
(* trySubst: try to substitute tokens for the current terminal;
|
||||
return a list of the successes *)
|
||||
|
||||
|
@ -447,7 +447,7 @@ fun mkFixError({is_keyword,terms,errtermvalue,
|
|||
SOME(tok::deleted,l,r',lp'')
|
||||
| NONE => NONE
|
||||
else NONE
|
||||
|
||||
|
||||
fun tryPreferred((stack,lexPair),queuePos) =
|
||||
catList preferred_change (fn (delete,insert) =>
|
||||
if List.exists noShift delete then [] (* should give warning at
|
||||
|
@ -490,7 +490,7 @@ fun mkFixError({is_keyword,terms,errtermvalue,
|
|||
" with " ^ (showTerms new)
|
||||
in error ("syntax error: " ^ s,leftPos,rightPos)
|
||||
end
|
||||
|
||||
|
||||
val _ =
|
||||
(if length l > 1 andalso DEBUG2 then
|
||||
(print "multiple fixes possible; could fix it by:\n";
|
||||
|
@ -519,7 +519,7 @@ fun mkFixError({is_keyword,terms,errtermvalue,
|
|||
end
|
||||
in f (rev stateList,n)
|
||||
end
|
||||
|
||||
|
||||
val CHANGE {pos,orig,new,...} = change
|
||||
val (last,queueFront) = findNth pos
|
||||
val (stack,lexPair) = last
|
||||
|
|
|
@ -48,7 +48,7 @@ functor mkCore(structure IntGrammar : INTGRAMMAR) : CORE =
|
|||
val eq = eqItem
|
||||
val gt = gtItem
|
||||
end)
|
||||
|
||||
|
||||
open ItemList
|
||||
datatype core = CORE of item list * int
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ structure IntGrammar : INTGRAMMAR =
|
|||
num: int,(* internal # assigned by coreutils *)
|
||||
rulenum: int,
|
||||
precedence: int option}
|
||||
|
||||
|
||||
val eqTerm = (op =)
|
||||
val gtTerm = fn (T i,T j) => i>j
|
||||
|
||||
|
@ -98,7 +98,7 @@ structure IntGrammar : INTGRAMMAR =
|
|||
())
|
||||
else ())
|
||||
end
|
||||
|
||||
|
||||
val prGrammar =
|
||||
fn (a as (symbolToString,nontermToString,print)) =>
|
||||
fn (GRAMMAR {rules,terms,nonterms,start,...}) =>
|
||||
|
|
|
@ -45,7 +45,7 @@ functor HeaderFun () : HEADER =
|
|||
fn (s : string,i : TextIO.instream ,errs : TextIO.outstream) =>
|
||||
{name=s,errStream=errs,inStream=i,
|
||||
errorOccurred = ref false}
|
||||
|
||||
|
||||
val errorOccurred = fn (s : inputSource) =>fn () => !(#errorOccurred s)
|
||||
|
||||
val pr = fn out : TextIO.outstream => fn s : string => TextIO.output(out,s)
|
||||
|
@ -80,7 +80,7 @@ functor HeaderFun () : HEADER =
|
|||
NSHIFT of symbol list | POS of string | PURE |
|
||||
PARSE_ARG of string * string |
|
||||
TOKEN_SIG_INFO of string
|
||||
|
||||
|
||||
datatype declData = DECL of
|
||||
{eop : symbol list,
|
||||
keyword : symbol list,
|
||||
|
|
|
@ -42,7 +42,7 @@ functor mkLalr ( structure IntGrammar : INTGRAMMAR
|
|||
|
||||
datatype tmpcore = TMPCORE of (item * term list ref) list * int
|
||||
datatype lcore = LCORE of (item * term list) list * int
|
||||
|
||||
|
||||
|
||||
val prLcore =
|
||||
fn a as (SymbolToString,nontermToString,termToString,print) =>
|
||||
|
@ -136,7 +136,7 @@ functor mkLalr ( structure IntGrammar : INTGRAMMAR
|
|||
rule has proven to be nullable so far.
|
||||
Remember that the rhs has been reversed,
|
||||
implying that this is true initially *)
|
||||
|
||||
|
||||
(* A -> .z t B y, where y is nullable *)
|
||||
|
||||
let fun f (NONTERM b :: (r as (TERM _ :: _))) =
|
||||
|
@ -154,7 +154,7 @@ functor mkLalr ( structure IntGrammar : INTGRAMMAR
|
|||
| f _ = raise Fail "f"
|
||||
in f l
|
||||
end
|
||||
|
||||
|
||||
val check_rule = fn (rule as RULE {num,...}) =>
|
||||
let val pos = rule_pos rule
|
||||
in (print "look_pos: ";
|
||||
|
@ -219,10 +219,10 @@ functor mkLalr ( structure IntGrammar : INTGRAMMAR
|
|||
raise Find)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
(* findRuleRefs: state -> rule -> lookahead refs for rule. *)
|
||||
|
||||
|
||||
val findRuleRefs =
|
||||
let val shift = shift graph
|
||||
in fn state =>
|
||||
|
@ -240,7 +240,7 @@ functor mkLalr ( structure IntGrammar : INTGRAMMAR
|
|||
findRef(state,ITEM{rule=rule,
|
||||
dot=pos,
|
||||
rhsAfter=rhs})::result)
|
||||
|
||||
|
||||
(* find first item of the form A -> x .B y, where y =*=> epsilon and
|
||||
x is not epsilon, or A -> x. use scan' to pick up all refs after this
|
||||
point *)
|
||||
|
|
|
@ -47,7 +47,7 @@ functor mkLook (structure IntGrammar : INTGRAMMAR) : LOOK =
|
|||
val eq = eqNonterm
|
||||
val gt = gtNonterm
|
||||
end)
|
||||
|
||||
|
||||
val mkFuncs = fn {rules : rule list, nonterms : int,
|
||||
produces : nonterm -> rule list} =>
|
||||
|
||||
|
@ -172,7 +172,7 @@ functor mkLook (structure IntGrammar : INTGRAMMAR) : LOOK =
|
|||
of true => nullable_string r
|
||||
| f => f)
|
||||
| nullable_string nil = true
|
||||
|
||||
|
||||
in {nullable = nullable, first = prefix}
|
||||
end
|
||||
end;
|
||||
|
|
|
@ -155,11 +155,11 @@ some reductions are removed from the list before conflicting reductions
|
|||
can be compared against them. All reduce/reduce conflicts, however,
|
||||
can be generated given a list of the reduce/reduce conflicts generated
|
||||
by this method.
|
||||
|
||||
|
||||
This can be done by taking the transitive closure of the relation given
|
||||
by the list. If reduce/reduce (a,b) and reduce/reduce (b,c) are true,
|
||||
then reduce/reduce (a,c) is true. The relation is symmetric and transitive.
|
||||
|
||||
|
||||
Adding shifts:
|
||||
|
||||
Finally scan the list merging in shifts and resolving conflicts
|
||||
|
@ -301,7 +301,7 @@ is true.
|
|||
in ((pruneError actions,ERROR),gotos,errs1@errs2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
val mkTable = fn (grammar as GRAMMAR{rules,terms,nonterms,start,
|
||||
precedence,termToString,noshift,
|
||||
|
@ -327,13 +327,13 @@ is true.
|
|||
fun zip (h::t,h'::t') = (h,h') :: zip(t,t')
|
||||
| zip (nil,nil) = nil
|
||||
| zip _ = let exception MkTable in raise MkTable end
|
||||
|
||||
|
||||
fun unzip l =
|
||||
let fun f ((a,b,c)::r,j,k,l) = f(r,a::j,b::k,c::l)
|
||||
| f (nil,j,k,l) = (rev j,rev k,rev l)
|
||||
in f(l,nil,nil,nil)
|
||||
end
|
||||
|
||||
|
||||
val (actions,gotos,errs) =
|
||||
let val doState =
|
||||
computeActions(rules,precedence,graph,
|
||||
|
|
|
@ -33,7 +33,7 @@ functor mkPrintStruct(structure LrTable : LR_TABLE
|
|||
|
||||
(* lineLength = approximately the largest number of characters to allow
|
||||
on a line when printing out an encode string *)
|
||||
|
||||
|
||||
val lineLength = 72
|
||||
|
||||
(* maxLength = length of a table entry. All table entries are encoded
|
||||
|
@ -121,7 +121,7 @@ functor mkPrintStruct(structure LrTable : LR_TABLE
|
|||
| (SHIFT (STATE i)) => printInt (i+2)
|
||||
| ACCEPT => printInt 0
|
||||
| ERROR => printInt 1
|
||||
|
||||
|
||||
val printTermAction = fn (T t,action) =>
|
||||
(printInt (t+1); printAction action)
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ functor EquivFun(A : EQUIV_ARG) : EQUIV =
|
|||
|
||||
We then return the length of R, R, and the list that results from
|
||||
permuting SE by P.
|
||||
*)
|
||||
*)
|
||||
|
||||
type entry = A.entry
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ signature HEADER =
|
|||
NSHIFT of symbol list | POS of string | PURE |
|
||||
PARSE_ARG of string * string |
|
||||
TOKEN_SIG_INFO of string
|
||||
|
||||
|
||||
datatype rule = RULE of {lhs : symbol, rhs : symbol list,
|
||||
code : string, prec : symbol option}
|
||||
|
||||
|
@ -95,7 +95,7 @@ signature PARSE_GEN =
|
|||
|
||||
signature GRAMMAR =
|
||||
sig
|
||||
|
||||
|
||||
datatype term = T of int
|
||||
datatype nonterm = NT of int
|
||||
datatype symbol = TERM of term | NONTERM of nonterm
|
||||
|
@ -138,7 +138,7 @@ signature INTGRAMMAR =
|
|||
|
||||
(* internal number of rule - convenient for producing LR graph *)
|
||||
|
||||
num : int,
|
||||
num : int,
|
||||
rulenum : int,
|
||||
precedence : int option}
|
||||
|
||||
|
@ -328,7 +328,7 @@ signature LR_ERRS =
|
|||
not_reduced : int, start : int,nonshift : int}
|
||||
|
||||
val printSummary : (string -> unit) -> err list -> unit
|
||||
|
||||
|
||||
end
|
||||
|
||||
(* PRINT_STRUCT: prints a structure which includes a value 'table' and a
|
||||
|
|
|
@ -144,7 +144,7 @@ struct
|
|||
|
||||
val gotoTableSize = ref 0
|
||||
val actionTableSize = ref 0
|
||||
|
||||
|
||||
val _ = if length errs > 0
|
||||
then (printSummary print errs;
|
||||
print "\n";
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
functor MlyaccLrValsFun(structure Hdr : HEADER
|
||||
where type prec = Header.prec
|
||||
structure Token : TOKEN)
|
||||
=
|
||||
=
|
||||
struct
|
||||
structure ParserData=
|
||||
struct
|
||||
structure Header =
|
||||
structure Header =
|
||||
struct
|
||||
(* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi *)
|
||||
|
||||
|
@ -21,7 +21,7 @@ open Hdr
|
|||
end
|
||||
structure LrTable = Token.LrTable
|
||||
structure Token = Token
|
||||
local open LrTable in
|
||||
local open LrTable in
|
||||
val table=let val actionRows =
|
||||
"\
|
||||
\\001\000\001\000\076\000\000\000\
|
||||
|
@ -251,7 +251,7 @@ val gotoT =
|
|||
val numstates = 104
|
||||
val numrules = 55
|
||||
val s = ref "" and index = ref 0
|
||||
val string_to_int = fn () =>
|
||||
val string_to_int = fn () =>
|
||||
let val i = !index
|
||||
in index := i+2; Char.ord(String.sub(!s,i)) + Char.ord(String.sub(!s,i+1)) * 256
|
||||
end
|
||||
|
@ -309,7 +309,7 @@ end
|
|||
local open Header in
|
||||
type pos = int
|
||||
type arg = Hdr.inputSource
|
||||
structure MlyValue =
|
||||
structure MlyValue =
|
||||
struct
|
||||
datatype svalue = VOID | ntVOID of unit -> unit
|
||||
| UNKNOWN of unit -> (string) | TYVAR of unit -> (string)
|
||||
|
@ -333,16 +333,16 @@ datatype svalue = VOID | ntVOID of unit -> unit
|
|||
| BEGIN of unit -> (string*Hdr.declData* ( Hdr.rule list ) )
|
||||
end
|
||||
type svalue = MlyValue.svalue
|
||||
type result = string*Hdr.declData* ( Hdr.rule list )
|
||||
type result = string*Hdr.declData* ( Hdr.rule list )
|
||||
end
|
||||
structure EC=
|
||||
struct
|
||||
open LrTable
|
||||
val is_keyword =
|
||||
fn _ => false
|
||||
val preferred_change =
|
||||
val preferred_change =
|
||||
nil
|
||||
val noShift =
|
||||
val noShift =
|
||||
fn (T 8) => true | _ => false
|
||||
val showTerminal =
|
||||
fn (T 0) => "ARROW"
|
||||
|
@ -399,17 +399,17 @@ val terms = (T 0) :: (T 1) :: (T 2) :: (T 3) :: (T 4) :: (T 5) :: (T 6
|
|||
:: (T 34) :: (T 35) :: (T 36) :: (T 38) :: (T 39) :: (T 41) :: nil
|
||||
end
|
||||
structure Actions =
|
||||
struct
|
||||
struct
|
||||
type int = Int.int
|
||||
exception mlyAction of int
|
||||
local open Header in
|
||||
val actions =
|
||||
val actions =
|
||||
fn (i392:int,defaultPos,stack,
|
||||
(inputSource):arg) =>
|
||||
case (i392,stack)
|
||||
of (0,(_,(MlyValue.G_RULE_LIST G_RULE_LIST1,_,G_RULE_LIST1right))::_::
|
||||
(_,(MlyValue.MPC_DECLS MPC_DECLS1,_,_))::(_,(MlyValue.HEADER HEADER1,
|
||||
HEADER1left,_))::rest671) => let val result=MlyValue.BEGIN(fn _ =>
|
||||
HEADER1left,_))::rest671) => let val result=MlyValue.BEGIN(fn _ =>
|
||||
let val HEADER as HEADER1=HEADER1 ()
|
||||
val MPC_DECLS as MPC_DECLS1=MPC_DECLS1 ()
|
||||
val G_RULE_LIST as G_RULE_LIST1=G_RULE_LIST1 ()
|
||||
|
@ -417,7 +417,7 @@ val G_RULE_LIST as G_RULE_LIST1=G_RULE_LIST1 ()
|
|||
)
|
||||
in (LrTable.NT 0,(result,HEADER1left,G_RULE_LIST1right),rest671) end
|
||||
| (1,(_,(MlyValue.MPC_DECL MPC_DECL1,MPC_DECLleft,MPC_DECL1right))::(_
|
||||
,(MlyValue.MPC_DECLS MPC_DECLS1,MPC_DECLS1left,_))::rest671) => let
|
||||
,(MlyValue.MPC_DECLS MPC_DECLS1,MPC_DECLS1left,_))::rest671) => let
|
||||
val result=MlyValue.MPC_DECLS(fn _ => let val MPC_DECLS as MPC_DECLS1=
|
||||
MPC_DECLS1 ()
|
||||
val MPC_DECL as MPC_DECL1=MPC_DECL1 ()
|
||||
|
@ -431,7 +431,7 @@ DECL {prec=nil,nonterm=NONE,term=NONE,eop=nil,control=nil,
|
|||
))
|
||||
in (LrTable.NT 5,(result,defaultPos,defaultPos),rest671) end
|
||||
| (3,(_,(MlyValue.CONSTR_LIST CONSTR_LIST1,_,CONSTR_LIST1right))::(_,(
|
||||
_,TERM1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
_,TERM1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
let val CONSTR_LIST as CONSTR_LIST1=CONSTR_LIST1 ()
|
||||
in (
|
||||
DECL { prec=nil,nonterm=NONE,
|
||||
|
@ -472,7 +472,7 @@ DECL {prec=nil,control=[START_SYM (symbolMake ID)],nonterm=NONE,
|
|||
)
|
||||
in (LrTable.NT 4,(result,START1left,ID1right),rest671) end
|
||||
| (7,(_,(MlyValue.ID_LIST ID_LIST1,_,ID_LIST1right))::(_,(_,
|
||||
PERCENT_EOP1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn
|
||||
PERCENT_EOP1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn
|
||||
_ => let val ID_LIST as ID_LIST1=ID_LIST1 ()
|
||||
in (
|
||||
DECL {prec=nil,control=nil,nonterm=NONE,term=NONE,
|
||||
|
@ -492,7 +492,7 @@ DECL {prec=nil,control=nil,nonterm=NONE,term=NONE,eop=nil,
|
|||
)
|
||||
in (LrTable.NT 4,(result,KEYWORD1left,ID_LIST1right),rest671) end
|
||||
| (9,(_,(MlyValue.ID_LIST ID_LIST1,_,ID_LIST1right))::(_,(_,
|
||||
PREFER1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
PREFER1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
let val ID_LIST as ID_LIST1=ID_LIST1 ()
|
||||
in (
|
||||
DECL {prec=nil,control=nil,nonterm=NONE,term=NONE,eop=nil,
|
||||
|
@ -512,7 +512,7 @@ DECL {prec=nil,control=nil,nonterm=NONE,term=NONE,eop=nil,
|
|||
)
|
||||
in (LrTable.NT 4,(result,CHANGE1left,CHANGE_DECL1right),rest671) end
|
||||
| (11,(_,(MlyValue.SUBST_DECL SUBST_DECL1,_,SUBST_DECL1right))::(_,(_,
|
||||
SUBST1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
SUBST1left,_))::rest671) => let val result=MlyValue.MPC_DECL(fn _ =>
|
||||
let val SUBST_DECL as SUBST_DECL1=SUBST_DECL1 ()
|
||||
in (
|
||||
DECL {prec=nil,control=nil,nonterm=NONE,term=NONE,eop=nil,
|
||||
|
@ -581,7 +581,7 @@ DECL {prec=nil,control=[Hdr.VERBOSE],
|
|||
value=nil}
|
||||
))
|
||||
in (LrTable.NT 4,(result,VERBOSE1left,VERBOSE1right),rest671) end
|
||||
| (18,(_,(_,NODEFAULT1left,NODEFAULT1right))::rest671) => let val
|
||||
| (18,(_,(_,NODEFAULT1left,NODEFAULT1right))::rest671) => let val
|
||||
result=MlyValue.MPC_DECL(fn _ => (
|
||||
DECL {prec=nil,control=[Hdr.NODEFAULT],
|
||||
nonterm=NONE,term=NONE,eop=nil,
|
||||
|
@ -589,7 +589,7 @@ DECL {prec=nil,control=[Hdr.NODEFAULT],
|
|||
value=nil}
|
||||
))
|
||||
in (LrTable.NT 4,(result,NODEFAULT1left,NODEFAULT1right),rest671) end
|
||||
| (19,(_,(_,PERCENT_PURE1left,PERCENT_PURE1right))::rest671) => let
|
||||
| (19,(_,(_,PERCENT_PURE1left,PERCENT_PURE1right))::rest671) => let
|
||||
val result=MlyValue.MPC_DECL(fn _ => (
|
||||
DECL {prec=nil,control=[Hdr.PURE],
|
||||
nonterm=NONE,term=NONE,eop=nil,
|
||||
|
@ -622,8 +622,8 @@ DECL {prec=nil,control=nil,
|
|||
)
|
||||
in (LrTable.NT 4,(result,VALUE1left,PROG1right),rest671) end
|
||||
| (22,(_,(MlyValue.CHANGE_DECL CHANGE_DECL1,_,CHANGE_DECL1right))::_::
|
||||
(_,(MlyValue.CHANGE_DEC CHANGE_DEC1,CHANGE_DEC1left,_))::rest671) =>
|
||||
let val result=MlyValue.CHANGE_DECL(fn _ => let val CHANGE_DEC as
|
||||
(_,(MlyValue.CHANGE_DEC CHANGE_DEC1,CHANGE_DEC1left,_))::rest671) =>
|
||||
let val result=MlyValue.CHANGE_DECL(fn _ => let val CHANGE_DEC as
|
||||
CHANGE_DEC1=CHANGE_DEC1 ()
|
||||
val CHANGE_DECL as CHANGE_DECL1=CHANGE_DECL1 ()
|
||||
in (CHANGE_DEC :: CHANGE_DECL) end
|
||||
|
@ -645,7 +645,7 @@ val ID_LIST2=ID_LIST2 ()
|
|||
)
|
||||
in (LrTable.NT 15,(result,ID_LIST1left,ID_LIST2right),rest671) end
|
||||
| (25,(_,(MlyValue.SUBST_DECL SUBST_DECL1,_,SUBST_DECL1right))::_::(_,
|
||||
(MlyValue.SUBST_DEC SUBST_DEC1,SUBST_DEC1left,_))::rest671) => let
|
||||
(MlyValue.SUBST_DEC SUBST_DEC1,SUBST_DEC1left,_))::rest671) => let
|
||||
val result=MlyValue.SUBST_DECL(fn _ => let val SUBST_DEC as SUBST_DEC1
|
||||
=SUBST_DEC1 ()
|
||||
val SUBST_DECL as SUBST_DECL1=SUBST_DECL1 ()
|
||||
|
@ -654,14 +654,14 @@ val SUBST_DECL as SUBST_DECL1=SUBST_DECL1 ()
|
|||
in (LrTable.NT 12,(result,SUBST_DEC1left,SUBST_DECL1right),rest671)
|
||||
end
|
||||
| (26,(_,(MlyValue.SUBST_DEC SUBST_DEC1,SUBST_DEC1left,SUBST_DEC1right
|
||||
))::rest671) => let val result=MlyValue.SUBST_DECL(fn _ => let val
|
||||
))::rest671) => let val result=MlyValue.SUBST_DECL(fn _ => let val
|
||||
SUBST_DEC as SUBST_DEC1=SUBST_DEC1 ()
|
||||
in ([SUBST_DEC]) end
|
||||
)
|
||||
in (LrTable.NT 12,(result,SUBST_DEC1left,SUBST_DEC1right),rest671)
|
||||
end
|
||||
| (27,(_,(MlyValue.ID ID2,_,ID2right))::_::(_,(MlyValue.ID ID1,ID1left
|
||||
,_))::rest671) => let val result=MlyValue.SUBST_DEC(fn _ => let val
|
||||
,_))::rest671) => let val result=MlyValue.SUBST_DEC(fn _ => let val
|
||||
ID1=ID1 ()
|
||||
val ID2=ID2 ()
|
||||
in ([symbolMake ID2],[symbolMake ID1]) end
|
||||
|
@ -676,7 +676,7 @@ val TY as TY1=TY1 ()
|
|||
in ((symbolMake ID,SOME (tyMake TY))::CONSTR_LIST) end
|
||||
)
|
||||
in (LrTable.NT 1,(result,CONSTR_LIST1left,TY1right),rest671) end
|
||||
| (29,(_,(MlyValue.ID ID1,_,ID1right))::_::(_,(MlyValue.CONSTR_LIST
|
||||
| (29,(_,(MlyValue.ID ID1,_,ID1right))::_::(_,(MlyValue.CONSTR_LIST
|
||||
CONSTR_LIST1,CONSTR_LIST1left,_))::rest671) => let val result=
|
||||
MlyValue.CONSTR_LIST(fn _ => let val CONSTR_LIST as CONSTR_LIST1=
|
||||
CONSTR_LIST1 ()
|
||||
|
@ -685,13 +685,13 @@ val ID as ID1=ID1 ()
|
|||
)
|
||||
in (LrTable.NT 1,(result,CONSTR_LIST1left,ID1right),rest671) end
|
||||
| (30,(_,(MlyValue.TY TY1,_,TY1right))::_::(_,(MlyValue.ID ID1,ID1left
|
||||
,_))::rest671) => let val result=MlyValue.CONSTR_LIST(fn _ => let val
|
||||
,_))::rest671) => let val result=MlyValue.CONSTR_LIST(fn _ => let val
|
||||
ID as ID1=ID1 ()
|
||||
val TY as TY1=TY1 ()
|
||||
in ([(symbolMake ID,SOME (tyMake TY))]) end
|
||||
)
|
||||
in (LrTable.NT 1,(result,ID1left,TY1right),rest671) end
|
||||
| (31,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
| (31,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
result=MlyValue.CONSTR_LIST(fn _ => let val ID as ID1=ID1 ()
|
||||
in ([(symbolMake ID,NONE)]) end
|
||||
)
|
||||
|
@ -709,21 +709,21 @@ map (fn {rhs,code,prec} =>
|
|||
)
|
||||
in (LrTable.NT 9,(result,ID1left,RHS_LIST1right),rest671) end
|
||||
| (33,(_,(MlyValue.G_RULE G_RULE1,_,G_RULE1right))::(_,(
|
||||
MlyValue.G_RULE_LIST G_RULE_LIST1,G_RULE_LIST1left,_))::rest671) =>
|
||||
let val result=MlyValue.G_RULE_LIST(fn _ => let val G_RULE_LIST as
|
||||
MlyValue.G_RULE_LIST G_RULE_LIST1,G_RULE_LIST1left,_))::rest671) =>
|
||||
let val result=MlyValue.G_RULE_LIST(fn _ => let val G_RULE_LIST as
|
||||
G_RULE_LIST1=G_RULE_LIST1 ()
|
||||
val G_RULE as G_RULE1=G_RULE1 ()
|
||||
in (G_RULE@G_RULE_LIST) end
|
||||
)
|
||||
in (LrTable.NT 10,(result,G_RULE_LIST1left,G_RULE1right),rest671) end
|
||||
| (34,(_,(MlyValue.G_RULE G_RULE1,G_RULE1left,G_RULE1right))::rest671)
|
||||
=> let val result=MlyValue.G_RULE_LIST(fn _ => let val G_RULE as
|
||||
=> let val result=MlyValue.G_RULE_LIST(fn _ => let val G_RULE as
|
||||
G_RULE1=G_RULE1 ()
|
||||
in (G_RULE) end
|
||||
)
|
||||
in (LrTable.NT 10,(result,G_RULE1left,G_RULE1right),rest671) end
|
||||
| (35,(_,(MlyValue.ID_LIST ID_LIST1,_,ID_LIST1right))::(_,(MlyValue.ID
|
||||
ID1,ID1left,_))::rest671) => let val result=MlyValue.ID_LIST(fn _ =>
|
||||
ID1,ID1left,_))::rest671) => let val result=MlyValue.ID_LIST(fn _ =>
|
||||
let val ID as ID1=ID1 ()
|
||||
val ID_LIST as ID_LIST1=ID_LIST1 ()
|
||||
in (symbolMake ID :: ID_LIST) end
|
||||
|
@ -742,7 +742,7 @@ val PROG as PROG1=PROG1 ()
|
|||
in (LrTable.NT 8,(result,ID_LIST1left,PROG1right),rest671) end
|
||||
| (38,(_,(MlyValue.PROG PROG1,_,PROG1right))::(_,(MlyValue.G_RULE_PREC
|
||||
G_RULE_PREC1,_,_))::(_,(MlyValue.ID_LIST ID_LIST1,_,_))::_::(_,(
|
||||
MlyValue.RHS_LIST RHS_LIST1,RHS_LIST1left,_))::rest671) => let val
|
||||
MlyValue.RHS_LIST RHS_LIST1,RHS_LIST1left,_))::rest671) => let val
|
||||
result=MlyValue.RHS_LIST(fn _ => let val RHS_LIST as RHS_LIST1=
|
||||
RHS_LIST1 ()
|
||||
val ID_LIST as ID_LIST1=ID_LIST1 ()
|
||||
|
@ -751,47 +751,47 @@ val PROG as PROG1=PROG1 ()
|
|||
in ({rhs=ID_LIST,code=PROG,prec=G_RULE_PREC}::RHS_LIST) end
|
||||
)
|
||||
in (LrTable.NT 8,(result,RHS_LIST1left,PROG1right),rest671) end
|
||||
| (39,(_,(MlyValue.TYVAR TYVAR1,TYVAR1left,TYVAR1right))::rest671) =>
|
||||
| (39,(_,(MlyValue.TYVAR TYVAR1,TYVAR1left,TYVAR1right))::rest671) =>
|
||||
let val result=MlyValue.TY(fn _ => let val TYVAR as TYVAR1=TYVAR1 ()
|
||||
in (TYVAR) end
|
||||
)
|
||||
in (LrTable.NT 16,(result,TYVAR1left,TYVAR1right),rest671) end
|
||||
| (40,(_,(_,_,RBRACE1right))::(_,(MlyValue.RECORD_LIST RECORD_LIST1,_,
|
||||
_))::(_,(_,LBRACE1left,_))::rest671) => let val result=MlyValue.TY(fn
|
||||
_))::(_,(_,LBRACE1left,_))::rest671) => let val result=MlyValue.TY(fn
|
||||
_ => let val RECORD_LIST as RECORD_LIST1=RECORD_LIST1 ()
|
||||
in ("{ "^RECORD_LIST^" } ") end
|
||||
)
|
||||
in (LrTable.NT 16,(result,LBRACE1left,RBRACE1right),rest671) end
|
||||
| (41,(_,(_,_,RBRACE1right))::(_,(_,LBRACE1left,_))::rest671) => let
|
||||
| (41,(_,(_,_,RBRACE1right))::(_,(_,LBRACE1left,_))::rest671) => let
|
||||
val result=MlyValue.TY(fn _ => ("{}"))
|
||||
in (LrTable.NT 16,(result,LBRACE1left,RBRACE1right),rest671) end
|
||||
| (42,(_,(MlyValue.PROG PROG1,PROG1left,PROG1right))::rest671) => let
|
||||
| (42,(_,(MlyValue.PROG PROG1,PROG1left,PROG1right))::rest671) => let
|
||||
val result=MlyValue.TY(fn _ => let val PROG as PROG1=PROG1 ()
|
||||
in (" ( "^PROG^" ) ") end
|
||||
)
|
||||
in (LrTable.NT 16,(result,PROG1left,PROG1right),rest671) end
|
||||
| (43,(_,(MlyValue.QUAL_ID QUAL_ID1,_,QUAL_ID1right))::(_,(MlyValue.TY
|
||||
TY1,TY1left,_))::rest671) => let val result=MlyValue.TY(fn _ => let
|
||||
TY1,TY1left,_))::rest671) => let val result=MlyValue.TY(fn _ => let
|
||||
val TY as TY1=TY1 ()
|
||||
val QUAL_ID as QUAL_ID1=QUAL_ID1 ()
|
||||
in (TY^" "^QUAL_ID) end
|
||||
)
|
||||
in (LrTable.NT 16,(result,TY1left,QUAL_ID1right),rest671) end
|
||||
| (44,(_,(MlyValue.QUAL_ID QUAL_ID1,QUAL_ID1left,QUAL_ID1right))::
|
||||
rest671) => let val result=MlyValue.TY(fn _ => let val QUAL_ID as
|
||||
rest671) => let val result=MlyValue.TY(fn _ => let val QUAL_ID as
|
||||
QUAL_ID1=QUAL_ID1 ()
|
||||
in (QUAL_ID) end
|
||||
)
|
||||
in (LrTable.NT 16,(result,QUAL_ID1left,QUAL_ID1right),rest671) end
|
||||
| (45,(_,(MlyValue.TY TY2,_,TY2right))::_::(_,(MlyValue.TY TY1,TY1left
|
||||
,_))::rest671) => let val result=MlyValue.TY(fn _ => let val TY1=TY1
|
||||
,_))::rest671) => let val result=MlyValue.TY(fn _ => let val TY1=TY1
|
||||
()
|
||||
val TY2=TY2 ()
|
||||
in (TY1^"*"^TY2) end
|
||||
)
|
||||
in (LrTable.NT 16,(result,TY1left,TY2right),rest671) end
|
||||
| (46,(_,(MlyValue.TY TY2,_,TY2right))::_::(_,(MlyValue.TY TY1,TY1left
|
||||
,_))::rest671) => let val result=MlyValue.TY(fn _ => let val TY1=TY1
|
||||
,_))::rest671) => let val result=MlyValue.TY(fn _ => let val TY1=TY1
|
||||
()
|
||||
val TY2=TY2 ()
|
||||
in (TY1 ^ " -> " ^ TY2) end
|
||||
|
@ -799,7 +799,7 @@ val TY2=TY2 ()
|
|||
in (LrTable.NT 16,(result,TY1left,TY2right),rest671) end
|
||||
| (47,(_,(MlyValue.TY TY1,_,TY1right))::_::(_,(MlyValue.LABEL LABEL1,_
|
||||
,_))::_::(_,(MlyValue.RECORD_LIST RECORD_LIST1,RECORD_LIST1left,_))::
|
||||
rest671) => let val result=MlyValue.RECORD_LIST(fn _ => let val
|
||||
rest671) => let val result=MlyValue.RECORD_LIST(fn _ => let val
|
||||
RECORD_LIST as RECORD_LIST1=RECORD_LIST1 ()
|
||||
val LABEL as LABEL1=LABEL1 ()
|
||||
val TY as TY1=TY1 ()
|
||||
|
@ -813,7 +813,7 @@ val TY as TY1=TY1 ()
|
|||
in (LABEL^":"^TY) end
|
||||
)
|
||||
in (LrTable.NT 7,(result,LABEL1left,TY1right),rest671) end
|
||||
| (49,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
| (49,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
result=MlyValue.QUAL_ID(fn _ => let val ID as ID1=ID1 ()
|
||||
in ((fn (a,_) => a) ID) end
|
||||
)
|
||||
|
@ -825,18 +825,18 @@ val QUAL_ID as QUAL_ID1=QUAL_ID1 ()
|
|||
in (IDDOT^QUAL_ID) end
|
||||
)
|
||||
in (LrTable.NT 6,(result,IDDOT1left,QUAL_ID1right),rest671) end
|
||||
| (51,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
| (51,(_,(MlyValue.ID ID1,ID1left,ID1right))::rest671) => let val
|
||||
result=MlyValue.LABEL(fn _ => let val ID as ID1=ID1 ()
|
||||
in ((fn (a,_) => a) ID) end
|
||||
)
|
||||
in (LrTable.NT 3,(result,ID1left,ID1right),rest671) end
|
||||
| (52,(_,(MlyValue.INT INT1,INT1left,INT1right))::rest671) => let val
|
||||
| (52,(_,(MlyValue.INT INT1,INT1left,INT1right))::rest671) => let val
|
||||
result=MlyValue.LABEL(fn _ => let val INT as INT1=INT1 ()
|
||||
in (INT) end
|
||||
)
|
||||
in (LrTable.NT 3,(result,INT1left,INT1right),rest671) end
|
||||
| (53,(_,(MlyValue.ID ID1,_,ID1right))::(_,(_,PREC_TAG1left,_))::
|
||||
rest671) => let val result=MlyValue.G_RULE_PREC(fn _ => let val ID as
|
||||
rest671) => let val result=MlyValue.G_RULE_PREC(fn _ => let val ID as
|
||||
ID1=ID1 ()
|
||||
in (SOME (symbolMake ID)) end
|
||||
)
|
||||
|
|
|
@ -74,7 +74,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
dataStruct:string, (* name of structure in Misc *)
|
||||
(* which holds parser data *)
|
||||
dataSig:string (* signature for this structure *)
|
||||
|
||||
|
||||
}
|
||||
|
||||
val DEBUG = true
|
||||
|
@ -109,7 +109,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
(* tokenInfo is the user inserted spec in
|
||||
the *_TOKEN sig*)
|
||||
tokenInfo : string option}
|
||||
|
||||
|
||||
structure SymbolHash = Hash(type elem = string
|
||||
val gt = (op >) : string*string -> bool)
|
||||
|
||||
|
@ -200,7 +200,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
in app f terms
|
||||
end;
|
||||
sayln "end")
|
||||
|
||||
|
||||
(* function to print signatures out - takes print function which
|
||||
does not need to insert line breaks *)
|
||||
|
||||
|
@ -223,7 +223,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
"\nsharing type " ^ dataStruct ^
|
||||
".Token.token = Tokens.token\nsharing type " ^
|
||||
dataStruct ^ ".svalue = Tokens.svalue\nend\n")
|
||||
|
||||
|
||||
(* function to print structure for error correction *)
|
||||
|
||||
val printEC = fn (keyword : term list,
|
||||
|
@ -270,7 +270,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
say "_ => ";
|
||||
say (valueStruct ^ ".");
|
||||
sayln termvoid; sayln "end")
|
||||
|
||||
|
||||
|
||||
val printNames = fn () =>
|
||||
let val f = fn term => (
|
||||
|
@ -289,7 +289,7 @@ functor ParseGenFun(structure ParseGenParser : PARSE_GEN_PARSER
|
|||
then r
|
||||
else t::r)
|
||||
[] terms
|
||||
|
||||
|
||||
in say "structure ";
|
||||
say ecStruct;
|
||||
sayln "=";
|
||||
|
@ -340,7 +340,7 @@ let val printAbsynRule = Absyn.printRule(say,sayln)
|
|||
PAPP(valueStruct^"."^ntvoid,
|
||||
PVAR symNum)
|
||||
else WILD)
|
||||
else
|
||||
else
|
||||
PAPP(valueStruct^"."^symString,
|
||||
if num=1 andalso pureActions
|
||||
then AS(PVAR symNum,PVAR symString)
|
||||
|
@ -573,7 +573,7 @@ let val printAbsynRule = Absyn.printRule(say,sayln)
|
|||
else (stmtError symbol; ~1))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
val nontermNum : string -> Header.symbol -> nonterm =
|
||||
let val nontermError = symError "nonterminal"
|
||||
in fn stmt =>
|
||||
|
@ -816,12 +816,12 @@ precedences of the rule and the terminal are equal.
|
|||
miscSig = name' ^ "_LRVALS",
|
||||
dataStruct = "ParserData",
|
||||
dataSig = "PARSER_DATA"}
|
||||
|
||||
|
||||
val (table,stateErrs,corePrint,errs) =
|
||||
MakeTable.mkTable(grammar,defaultReductions)
|
||||
|
||||
val entries = ref 0 (* save number of action table entries here *)
|
||||
|
||||
|
||||
in let val result = TextIO.openOut (spec ^ ".sml")
|
||||
val sigs = TextIO.openOut (spec ^ ".sig")
|
||||
val pos = ref 0
|
||||
|
|
Loading…
Reference in New Issue