## parse-mythryl.pkg
# Compiled by:
#
src/lib/compiler/front/parser/parser.sublibstipulate
package raw = raw_syntax; # raw_syntax is from
src/lib/compiler/front/parser/raw-syntax/raw-syntax.pkg package sci = sourcecode_info; # sourcecode_info is from
src/lib/compiler/front/basics/source/sourcecode-info.pkgherein
api Parse_Mythryl {
#
prompt_read_parse_and_return_one_toplevel_mythryl_expression
:
sci::Sourcecode_Info
-> Void
-> Null_Or( raw::Declaration );
parse_complete_mythryl_file
:
sci::Sourcecode_Info
-> raw::Declaration;
};
end;
stipulate
# package cex = compile_exception; # compilation_exception is from
src/lib/compiler/front/basics/map/compilation-exception.pkg package cos = compile_statistics; # compile_statistics is from
src/lib/compiler/front/basics/stats/compile-statistics.pkg package mpg = mythryl_parser_guts; # mythryl_parser_guts is from
src/lib/compiler/front/parser/main/mythryl-parser-guts.pkg package raw = raw_syntax; # raw_syntax is from
src/lib/compiler/front/parser/raw-syntax/raw-syntax.pkg package sci = sourcecode_info; # sourcecode_info is from
src/lib/compiler/front/basics/source/sourcecode-info.pkgherein
package parse_mythryl
: Parse_Mythryl
{
parse_phase = cos::make_compiler_phase "Compiler 010 parse";
#
fun fail string
=
raise exception (compilation_exception::COMPILE string);
#
fun prompt_read_parse_and_return_one_toplevel_mythryl_expression
#
(sourcecode_info: sci::Sourcecode_Info)
=
do_it
where
parser = mpg::prompt_read_parse_and_return_one_toplevel_mythryl_expression
#
sourcecode_info;
parser = cos::do_compiler_phase # Fold in compile-statistics stuff.
parse_phase
parser; # For correct timing
#
fun do_it ()
=
case (parser ())
#
mpg::RAW_DECLARATION
raw_declaration => THE raw_declaration;
#
mpg::END_OF_FILE => NULL;
mpg::PARSE_ERROR => fail "parse error";
esac;
end;
#
fun parse_complete_mythryl_file # Called (only) from
src/app/makelib/compilable/thawedlib-tome.pkg #
(sourcecode_info: sci::Sourcecode_Info)
=
parse_all_declarations_in_file NIL
where
parse_one_declaration
=
mpg::prompt_read_parse_and_return_one_toplevel_mythryl_expression
#
sourcecode_info;
parse_one_declaration # To collect compilation timing statistics.
=
cos::do_compiler_phase
parse_phase
parse_one_declaration;
#
fun parse_all_declarations_in_file raw_declarations
=
case (parse_one_declaration ()) # The below values get generated in
src/lib/compiler/front/parser/main/mythryl-parser-guts.pkg #
mpg::RAW_DECLARATION raw_declaration => parse_all_declarations_in_file (raw_declaration ! raw_declarations);
#
mpg::END_OF_FILE => raw::SEQUENTIAL_DECLARATIONS (reverse raw_declarations);
#
mpg::PARSE_ERROR => fail "syntax error";
esac;
end;
};
end;