PreviousUpNext

15.4.151  src/app/yacc/src/parse.pkg

#  Mythryl-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi 

# Compiled by:
#     src/app/yacc/src/mythryl-yacc.lib

###                     "We're fools whether we dance or not,
###                        so we might as well dance."
###
###                                     -- Japanese proverb



generic package parse_gen_parser_g (

    package header:  Header;            # Header        is from   src/app/yacc/src/header.api
    package parser:  Arg_Parser         # Arg_Parser    is from   src/app/yacc/lib/base.api

    where  Source_Position  ==  header::Source_Position;

    sharing parser::Result ==  header::Parse_Result;
    sharing parser::Arg    ==  header::Input_Source == parser::Lex_Arg;
)
: (weak) Parse_Gen_Parser               # Parse_Gen_Parser      is from   src/app/yacc/src/parse-gen-parser.api
{
    package header = header;

    fun parse file
        =
        (result, source)
        where  

            in_str =  file::open_for_read file;
            source =  header::make_source (file, in_str, file::stdout);

            error  = fn (s:  String, i: Int, _)
                         =
                         header::error source i s;

            stream =  parser::make_lexer
                          (fn i = (file::read_n (in_str, i)))
                          source;

            my (result, _)
                =
                {   header::lineno := 1; 
                    header::text   := NIL;
                    parser::parse (15, stream, error, source);
                };



            file::close_input in_str;
        end;
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext