(* available at top level *)
TOKEN
LR_TABLE
STREAM
LR_PARSER
PARSER_DATA
structure LrParser : LR_PARSER
(* printed out in .sig file created by parser generator: *)
signature {n}_TOKENS =
sig
structure Token : TOKEN
type svalue
val PLUS : 'pos * 'pos ->
(svalue,'pos) Token.token
val INTLIT : int * 'pos * 'pos ->
(svalue,'pos) Token.token
...
end
signature {n}_LRVALS =
sig
structure Tokens : {n}_TOKENS
structure ParserData : PARSER_DATA
sharing ParserData.Token = Tokens.Token
sharing type ParserData.svalue = Tokens.svalue
end
(* printed out by lexer generator: *)
functor {n}LexFun(structure Tokens : {n}_TOKENS)=
struct
...
end
(* printed out in .sml file created by parser generator: *)
functor {n}LrValsFun(structure Token : TOKENS) =
struct
structure ParserData =
struct
structure Token = Token
(* code in header section of specification *)
structure Header = ...
type svalue = ...
type result = ...
type pos = ...
structure Actions = ...
structure EC = ...
val table = ...
end
structure Tokens : {n}_TOKENS =
struct
structure Token = ParserData.Token
type svalue = ...
fun PLUS(p1,p2) = ...
fun INTLIT(i,p1,p2) = ...
end
end
(* to be done by the user: *)
structure {n}LrVals =
{n}LrValsFun(structure Token = LrParser.Token)
structure {n}Lex =
{n}LexFun(structure Tokens = {n}LrVals.Tokens)
structure {n}Parser =
Join(structure Lex = {n}Lex
structure ParserData = {n}ParserData
structure LrParser = LrParser)