File ‹$AFP/Isabelle_C/src_ext/mlton/lib/mlyacc-lib/base.sig›
signature STREAM1 =
sig type ('xa, 'xb) stream
val streamify : ((('stack * 'stack_ml * 'stack_pos * 'stack_tree) * 'arg) -> '_a * (('stack * 'stack_ml * 'stack_pos * 'stack_tree) * 'arg)) -> 'arg -> ('_a, (('stack * 'stack_ml * 'stack_pos * 'stack_tree) * 'arg)) stream * 'arg
val cons : '_a * (('_a, '_b) stream * '_b) -> ('_a, '_b) stream * '_b
val get : ('_a, '_b) stream * '_b -> '_a * (('_a, '_b) stream * '_b)
end
signature STREAM2 =
sig type 'xa stream
val streamify : (unit -> '_a) -> '_a stream
val cons : '_a * '_a stream -> '_a stream
val get : '_a stream -> '_a * '_a stream
end
signature LR_TABLE =
sig
datatype ('a,'b) pairlist = EMPTY | PAIR of 'a * 'b * ('a,'b) pairlist
datatype state = STATE of int
datatype term = T of int
datatype nonterm = NT of int
datatype action = SHIFT of state
| REDUCE of int
| ACCEPT
| ERROR
type table
val numStates : table -> int
val numRules : table -> int
val describeActions : table -> state ->
(term,action) pairlist * action
val describeGoto : table -> state -> (nonterm,state) pairlist
val action : table -> state * term -> action
val goto : table -> state * nonterm -> state
val initialState : table -> state
exception Goto of state * nonterm
val mkLrTable : {actions : ((term,action) pairlist * action) array,
gotos : (nonterm,state) pairlist array,
numStates : int, numRules : int,
initialState : state} -> table
end
signature TOKEN =
sig
structure LALR_Table : LR_TABLE
datatype ('a,'b) token = TOKEN of LALR_Table.term * ('a * 'b * 'b)
val sameToken : ('a,'b) token * ('a,'b) token -> bool
end
signature LR_PARSER1 =
sig
structure Stream : STREAM1
structure LALR_Table : LR_TABLE
structure Token : TOKEN
sharing LALR_Table = Token.LALR_Table
type ('_b, '_c) stack = (LALR_Table.state, '_b, '_c) C_Env.stack'
type ('_b, '_c, 'arg1, 'arg2) lexer = (('arg1 -> '_b * 'arg1,'_c) Token.token, ('_b, '_c) stack * 'arg1) Stream.stream * 'arg2
val parse : {table : LALR_Table.table,
saction : int *
'_c *
(LALR_Table.state * ('_b * '_c * '_c)) list *
'arg
-> LALR_Table.nonterm *
(('arg -> '_b * 'arg) * '_c * '_c) *
(LALR_Table.state * ('_b * '_c * '_c)) list,
void : 'arg -> '_b * 'arg,
void_position : '_c,
start : ('arg -> '_b * 'arg, '_c) Token.token,
accept : '_c * '_c -> ('_b, '_c) stack * 'arg -> 'user * 'arg,
reduce_init : (('_c * '_c) list * int) * 'arg -> 'arg,
reduce_get : (LALR_Table.state, '_b, '_c) C_Env.rule_reduce -> 'arg -> (LALR_Table.state, '_b, '_c) C_Env.rule_output0 * 'arg,
ec : { is_keyword : LALR_Table.term -> bool,
noShift : LALR_Table.term -> bool,
preferred_change : (LALR_Table.term list * LALR_Table.term list) list,
errtermvalue : LALR_Table.term -> 'arg -> '_b * 'arg,
showTerminal : LALR_Table.term -> string,
terms: LALR_Table.term list,
error : '_c * '_c -> ('_b, '_c) stack * 'arg -> 'user * 'arg
},
lookahead : int
}
-> ('_b, '_c, 'arg, 'arg) lexer
-> ('_b, '_c, 'arg, 'user * 'arg) lexer
end
signature LR_PARSER2 =
sig
structure Stream : STREAM2
structure LALR_Table : LR_TABLE
structure Token : TOKEN
sharing LALR_Table = Token.LALR_Table
exception ParseError
val parse : {table : LALR_Table.table,
lexer : ('_b,'_c) Token.token Stream.stream,
arg: 'arg,
saction : int *
'_c *
(LALR_Table.state * ('_b * '_c * '_c)) list *
'arg
-> LALR_Table.nonterm *
('_b * '_c * '_c) *
(LALR_Table.state * ('_b * '_c * '_c)) list,
void : '_b,
ec : { is_keyword : LALR_Table.term -> bool,
noShift : LALR_Table.term -> bool,
preferred_change : (LALR_Table.term list * LALR_Table.term list) list,
errtermvalue : LALR_Table.term -> '_b,
showTerminal : LALR_Table.term -> string,
terms: LALR_Table.term list,
error : string * '_c * '_c -> unit
},
lookahead : int
}
-> '_b * ('_b,'_c) Token.token Stream.stream
end
signature LEXER =
sig
structure LALR_Lex_Instance :
sig
type ('a,'b) token
type pos
type svalue
end
val makeLexer : (int -> string)
-> unit
-> (LALR_Lex_Instance.svalue, LALR_Lex_Instance.pos) LALR_Lex_Instance.token
end
signature ARG_LEXER1 =
sig
structure LALR_Lex_Instance :
sig
type ('a,'b) token
type pos
type arg
type svalue0
type svalue = arg -> svalue0 * arg
type state
end
type stack = (LALR_Lex_Instance.state, LALR_Lex_Instance.svalue0, LALR_Lex_Instance.pos) C_Env.stack'
val makeLexer : (stack * LALR_Lex_Instance.arg)
-> (LALR_Lex_Instance.svalue, LALR_Lex_Instance.pos) LALR_Lex_Instance.token
* (stack * LALR_Lex_Instance.arg)
end
signature ARG_LEXER2 =
sig
structure LALR_Lex_Instance :
sig
type ('a,'b) token
type pos
type arg
type svalue
end
val makeLexer : (int -> string)
-> LALR_Lex_Instance.arg
-> unit
-> (LALR_Lex_Instance.svalue,LALR_Lex_Instance.pos) LALR_Lex_Instance.token
end
signature PARSER_DATA1 =
sig
type pos
type arg
type svalue0
type svalue = arg -> svalue0 * arg
type result
structure LALR_Table : LR_TABLE
structure Token : TOKEN
sharing Token.LALR_Table = LALR_Table
structure Actions :
sig
val actions : int * pos * (LALR_Table.state * (svalue0 * pos * pos)) list * arg
-> LALR_Table.nonterm * (svalue * pos * pos) * (LALR_Table.state * (svalue0 * pos * pos)) list
val void : svalue
val extract : svalue0 -> result
end
structure EC :
sig
val is_keyword : LALR_Table.term -> bool
val noShift : LALR_Table.term -> bool
val preferred_change : (LALR_Table.term list * LALR_Table.term list) list
val errtermvalue : LALR_Table.term -> svalue
val showTerminal : LALR_Table.term -> string
val terms: LALR_Table.term list
end
val table : LALR_Table.table
end
signature PARSER_DATA2 =
sig
type pos
type arg
type svalue
type result
structure LALR_Table : LR_TABLE
structure Token : TOKEN
sharing Token.LALR_Table = LALR_Table
structure Actions :
sig
val actions : int * pos * (LALR_Table.state * (svalue * pos * pos)) list * arg
-> LALR_Table.nonterm * (svalue * pos * pos) * (LALR_Table.state * (svalue * pos * pos)) list
val void : svalue
val extract : svalue -> result
end
structure EC :
sig
val is_keyword : LALR_Table.term -> bool
val noShift : LALR_Table.term -> bool
val preferred_change : (LALR_Table.term list * LALR_Table.term list) list
val errtermvalue : LALR_Table.term -> svalue
val showTerminal : LALR_Table.term -> string
val terms: LALR_Table.term list
end
val table : LALR_Table.table
end
signature PARSER2 =
sig
structure Token : TOKEN
structure Stream : STREAM2
exception ParseError
type pos
type result
type arg
type svalue
val makeLexer : (int -> string)
-> (svalue, pos) Token.token Stream.stream
val parse : int * ((svalue, pos) Token.token Stream.stream) * (string * pos * pos -> unit) * arg
-> result * (svalue, pos) Token.token Stream.stream
val sameToken : (svalue, pos) Token.token * (svalue,pos) Token.token
-> bool
end
signature ARG_PARSER1 =
sig
structure Token : TOKEN
structure Stream : STREAM1
type arg
type pos
type svalue0
type svalue = arg -> svalue0 * arg
type stack = (Token.LALR_Table.state, svalue0, pos) C_Env.stack'
type ('arg1, 'arg2) lexer = ((svalue, pos) Token.token, stack * 'arg1) Stream.stream * 'arg2
val makeLexer : arg -> (arg, arg) lexer
val parse : int
* (pos * pos -> stack * arg -> 'user * arg)
* pos
* (svalue, pos) Token.token
* (pos * pos -> stack * arg -> 'user * arg)
* (((pos * pos) list * int) * arg -> arg)
* ((Token.LALR_Table.state, svalue0, pos) C_Env.rule_reduce -> arg -> (Token.LALR_Table.state, svalue0, pos) C_Env.rule_output0 * arg)
-> (arg, arg) lexer
-> (arg, 'user * arg) lexer
val sameToken : (svalue, pos) Token.token * (svalue, pos) Token.token -> bool
end
signature ARG_PARSER2 =
sig
structure Token : TOKEN
structure Stream : STREAM2
exception ParseError
type arg
type pos
type result
type svalue
val makeLexer : (int -> string) -> arg
-> (svalue, pos) Token.token Stream.stream
val parse : int * ((svalue, pos) Token.token Stream.stream) * (string * pos * pos -> unit) * arg
-> result * (svalue, pos) Token.token Stream.stream
val sameToken : (svalue, pos) Token.token * (svalue,pos) Token.token
-> bool
end