## parser.pkg
# Compiled by:
#
src/lib/c-kit/src/parser/c-parser.sublib### "C is peculiar in a lot of ways, but it,
### like many other successful things, has
### a certain unity of approach that stems
### from development in a small group."
###
### -- Dennis Ritchie
stipulate
package fil = file__premicrothread; # file__premicrothread is from
src/lib/std/src/posix/file--premicrothread.pkgherein
package c_parser
: (weak) C_Parser # C_Parser is from
src/lib/c-kit/src/parser/c-parser.api {
# Compute parser packages:
#
package lr_vals = lr_vals_g (package token = lr_parser::token;);
package tok_table = token_table_g (package tokens = lr_vals::tokens;);
package clex = clex_g (package tokens = lr_vals::tokens;
package tok_table = tok_table;);
package p = make_complete_yacc_parser_with_custom_argument_g (package parser_data = lr_vals::parser_data;
package lex = clex;
package lr_parser = lr_parser;);
fun parse_file err_state f =
{ type_defs::reset();
line_number_db = line_number_db::newmap { src_file=>f };
fun lex_err (p1, p2, msg) =
error::error (err_state, line_number_db::location line_number_db (p1, p2), msg);
fun lex_warn (p1, p2, msg) =
error::warning (err_state, line_number_db::location line_number_db (p1, p2), msg);
fun parse_err (msg, p1, p2) =
error::error (err_state, line_number_db::location line_number_db (p1, p2), msg);
fun inputc instrm i
=
fil::read_n (instrm, i);
lex_arg = { comment_nesting_depth => REF 0,
line_number_db,
charlist => REF ([] : List( String )),
stringstart => REF 0,
err_warn => { err=>lex_err, warn => lex_warn }
};
instrm = fil::open_for_read f;
lookahead = 15;
lexer = lr_parser::stream::streamify (clex::make_lexer (inputc instrm) lex_arg);
my (result, _) = p::parse (lookahead, lexer, parse_err, line_number_db);
fil::close_input instrm;
result;
}
except
p::PARSE_ERROR
=
{ fil::write (error::err_stream err_state, "PARSE_ERROR raised\n");
[];};
}; # package parser
end;
## Copyright (c) 1998 by Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.