PreviousUpNext

15.4.566  src/lib/compiler/front/parser/main/parse-nada.pkg

## parse-nada.pkg 

# Compiled by:
#     src/lib/compiler/front/parser/parser.sublib

# NB: None of the 'nada' stuff is current usable or used.
#     I'm keeping it as a place-holder in case I decide
#     to support an alternate syntax like prolog or lisp.


stipulate
    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.pkg
herein

    api Parse_Nada {

         prompt_read_parse_and_return_one_toplevel_nada_expression
            :
            sci::Sourcecode_Info
            ->
            Void
            ->
            Null_Or( raw::Declaration );

         parse_complete_nada_file
            :
            sci::Sourcecode_Info
            ->
            raw::Declaration;
    };
end;


stipulate
    package cex =  compilation_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 raw =  raw_syntax;                                          # raw_syntax            is from   src/lib/compiler/front/parser/raw-syntax/raw-syntax.pkg
herein

    package   parse_nada
    :         Parse_Nada
    {
        package p
            =
            nada_parser_guts;                                           # nada_parser_guts      is from   src/lib/compiler/front/parser/main/nada-parser-guts.pkg

        parse_phase
            =
            cos::make_compiler_phase "Compiler 010 parse";

        fun fail s
            =
            raise exception (cex::COMPILE s);

        fun prompt_read_parse_and_return_one_toplevel_nada_expression
                source
            =
            do_it
            where
                parser
                    =
                    p::prompt_read_parse_and_return_one_toplevel_nada_expression
                        source;

                parser
                    =
                    cos::do_compiler_phase
                        parse_phase
                        parser;                 #  For correct timing 

                fun do_it ()
                    =
                    case (parser ())

                         p::PARSE raw_syntax_tree =>  THE raw_syntax_tree;
                         p::EOF                   =>  NULL;
                         p::ABORT                 =>  fail "syntax error";
                         p::ERROR                 =>  fail "syntax error";
                    esac;
            end;


        fun parse_complete_nada_file
                source
            =
            loop NIL
            where
                parser =    p::prompt_read_parse_and_return_one_toplevel_nada_expression
                                #
                                source;

                parser =    cos::do_compiler_phase  parse_phase
                                #
                                parser;                         #  For correct timing. 

                fun loop raw_syntax_trees
                    = 
                    case (parser ())
                        #
                        p::PARSE raw_syntax_tree =>  loop (raw_syntax_tree ! raw_syntax_trees);
                        #
                        p::EOF                   =>  raw::SEQUENTIAL_DECLARATIONS (reverse raw_syntax_trees);
                        p::ABORT                 =>  fail "syntax error";
                        p::ERROR                 =>  fail "syntax error";
                    esac;
            end;
    };
end;



Comments and suggestions to: bugs@mythryl.org

PreviousUpNext