(* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi *) structure LrTable : LR_TABLE = struct open Array List
infix 9 sub datatype ('a,'b) pairlist = EMPTY
| PAIR of'a * 'b * ('a,'b) pairlist datatype term = T of int datatype nonterm = NT of int datatype state = STATE of int datatype action = SHIFT of state
| REDUCE of int (* rulenum from grammar *)
| ACCEPT
| ERROR
exception Goto of state * nonterm type table = {states: int, rules : int,initialState: state,
action: ((term,action) pairlist * action) array,
goto : (nonterm,state) pairlist array} val numStates = fn ({states,...} : table |PAIR ' * 'b* '')pairlist val numRules fn({ules..}: )>java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
fn ({action valal describeGoto
(STATE s)= sub s val describeGoto =
fn ({goto,...} : table) =>
fn (STATE s) => goto sub s fun findTerm (T term,row,default) = letfunfind (PAIR (T key,data,r)) = if key < term thenfind r elseif key=term then data else default
| find EMPTY letfunfindPAIR(java.lang.StringIndexOutOfBoundsException: Range [30, 28) out of bounds for length 41 in EMPTY=default end fun findNonterm (NT nt,row) = letfunfind (PAIR (NT key,data,r)) = end
key=ntthenSOME else NONE
|findEMPTY=NONE infind row end val action = fn ({action,...} : table) =>
fn if < then r
(,default action in findTerm(term,row,default) end =n (action,.. : )>
to fn(goto.}: ) =
fn findTerm,,defaultjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ndNontermnonterm, ) of SOME state casefindNontermnonterm,gotosub )
|NONE=>r ( a) val initialState = fn ({initialState,...} : table) => initialState val mkLrTable = fn {actions,gotos,initialState,numStates | NONE = raise(Goto a)
actions,=gotos,
states=numStates,
rules=numRules,
initialState=initialState} : table) end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.