#lang sml (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi * * $Log$ * Revision 1.1 2000/11/24 13:32:28 rossberg * *** empty log message *** * * Revision 1.1.1.1 1997/01/14 01:38:04 george * Version 109.24 * * Revision 1.1.1.1 1996/01/31 16:01:42 george * Version 109 * *) (* functor Join creates a user parser by putting together a Lexer structure, an LrValues structure, and a polymorphic parser structure. Note that the Lexer and LrValues structure must share the type pos (i.e. the type of line numbers), the type svalues for semantic values, and the type of tokens. *) functor Join(structure ParserData: PARSER_DATA structure Lex : LEXER structure LrParser : LR_PARSER sharing type ParserData.LrTable.state = LrParser.LrTable.state sharing type ParserData.LrTable.term = LrParser.LrTable.term sharing type ParserData.LrTable.nonterm = LrParser.LrTable.nonterm sharing type ParserData.LrTable.table = LrParser.LrTable.table sharing type ParserData.Token.token = LrParser.Token.token sharing type Lex.UserDeclarations.svalue = ParserData.svalue sharing type Lex.UserDeclarations.pos = ParserData.pos sharing type Lex.UserDeclarations.token = ParserData.Token.token) : PARSER = struct structure Token = ParserData.Token structure Stream = LrParser.Stream exception ParseError = LrParser.ParseError type arg = ParserData.arg type pos = ParserData.pos type result = ParserData.result type svalue = ParserData.svalue val makeLexer = LrParser.Stream.streamify o Lex.makeLexer val parse = fn (lookahead,lexer,error,arg) => (fn (a,b) => (ParserData.Actions.extract a,b)) (LrParser.parse {table = ParserData.table, lexer=lexer, lookahead=lookahead, saction = ParserData.Actions.actions, arg=arg, void= ParserData.Actions.void, ec = {is_keyword = ParserData.EC.is_keyword, noShift = ParserData.EC.noShift, preferred_change = ParserData.EC.preferred_change, errtermvalue = ParserData.EC.errtermvalue, error=error, showTerminal = ParserData.EC.showTerminal, terms = ParserData.EC.terms}} ) val sameToken = Token.sameToken end