PreviousUpNext

15.4.562  src/lib/compiler/front/parser/main/mythryl-parser.pkg

## mythryl-parser.pkg
## (C) 2001 Lucent Technologies, Bell Labs

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



# The Mythryl parser proper is implemented in
#
#     src/lib/compiler/front/parser/main/mythryl-parser-guts.pkg
#
# The external interface to it is implemented in
#
#     src/lib/compiler/front/parser/main/parse-mythryl.pkg



###       "Consistently separating words
###        by spaces became a general custom
###        about the tenth century A.D.,
###        and lasted until about 1957,
###        when FORTRAN abandoned the practice."
###
###                -- (Sun FORTRAN Reference Manual)



stipulate
    package fil =  file__premicrothread;                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
herein

    api Mythryl_Parser {
        #
        primary_prompt:                 Ref( String );
        secondary_prompt:               Ref( String );
        show_interactive_result_types:  Ref( Bool   );

        edit_request_stream:     Ref (Null_Or fil::Output_Stream);            # XXX SUCKO DELETEME this is temporary codebase conversion infrastructure


        # Turn on lazy keywords and lazy declaration processing:
        #
        lazy_is_a_keyword:              Ref( Bool );            #  Default FALSE.                  

        support_smlnj_antiquotes:       Ref( Bool );            # Controls backquote quotation.   Used (only) in src/lib/compiler/front/parser/lex/mythryl.lex

        print_interactive_prompts:      Ref( Bool );            # Used to enable interactive prompts for interactive users, and to disable those prompts when executing a script.
                                                                # Used in src/lib/compiler/front/parser/main/mythryl-parser-guts.pkg
                                                                # Used in src/lib/compiler/toplevel/interact/read-eval-print-loop-g.pkg
                                                                # Used in src/app/makelib/compile/compile-in-dependency-order-g.pkg
                                                                # Used in src/app/makelib/main/makelib-g.pkg
                                                                # Used in src/lib/core/internal/mythryld-app.pkg

        unparse_result:                 Ref( Bool );            # TRUE to have read-eval-print-loop unparse to stdout the result of evaluated expressions.
        log_edit_requests:              Ref( Bool );            # XXX BUGGO DELETEME this is temporary codebase conversion infrastructure

    };
end;


stipulate
    package bc  =  basic_control;                                       # basic_control                 is from   src/lib/compiler/front/basics/main/basic-control.pkg
    package ci  =  global_control_index;                                # global_control_index          is from   src/lib/global-controls/global-control-index.pkg
    package cj  =  global_control_junk;                                 # global_control_junk           is from   src/lib/global-controls/global-control-junk.pkg
    package ctl =  global_control;                                      # global_control                is from   src/lib/global-controls/global-control.pkg
    package fil =  file__premicrothread;                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
herein

    package   mythryl_parser
    : (weak)  Mythryl_Parser
    {
        menu_slot   =   [10, 10, 3];
        obscurity   =   3;
        prefix      =   "mythryl_parser";

        registry    =   ci::make { help => "parser settings" };
                                                                    my _ = 
        bc::note_subindex (prefix, registry, menu_slot);

        convert_string =  cj::cvt::string;
        convert_bool   =  cj::cvt::bool;

        next_menu_slot     = REF 0;

        fun make (c, name, help, d)
            =
            r
            where 

                r         =   REF d;
                menu_slot =   *next_menu_slot;

                control
                    =
                    ctl::make_control
                      {
                        name,
                        obscurity,
                        help,
                        menu_slot => [menu_slot],
                        control => r
                      };

                next_menu_slot := menu_slot + 1;

                ci::note_control
                  #
                  registry
                  #
                  {
                    control         => ctl::make_string_control  c  control,
                    #   
                    dictionary_name => THE (cj::dn::to_upper  "PARSER_"  name)
                  };
            end;


        primary_prompt
            =
            make (convert_string, "primary_prompt", "primary prompt", "\n\neval:  ");

        secondary_prompt
            =
            make (convert_string, "secondary_prompt", "secondary prompt", "more:  ");

        show_interactive_result_types
            =
            make ( convert_bool,
                   "show_interactive_result_types",
                   "whether to print types of interactively evaluated expressions",
                   FALSE
                 );


        # log_file is not intended to be user-settable,
        # so we don't create an actual control for it.
        # It's purpose is to communicate the per-source-file
        # logfile stream to mythryl.grammar actions.  Alas, there
        # doesn't seem to be a clean pipeline for passing
        # such info to them at present.   XXX BUGGO FIXME.
        # That makes this yet another bit of thread-unsafe
        # global mutable state... :-(

        edit_request_stream
            =
            REF (NULL: Null_Or fil::Output_Stream);            # XXX BUGGO DELETEME this is temporary codebase conversion infrastructure

        my log_edit_requests           # XXX BUGGO DELETEME this is temporary codebase conversion infrastructure
            =
            make (   convert_bool,
                     "log_edit_requests",
                     "whether to log per-source-file compile stuff",
                     FALSE
                 );

        lazy_is_a_keyword
            =
            make (   convert_bool,
                     "lazy_is_a_keyword",
                     "whether `lazy' is considered a keyword",
                     FALSE
                 );

        print_interactive_prompts
            =
            make (   convert_bool,
                     "print_interactive_prompts",
                     "TRUE for interactive use, FALSE when running scripts",
                     TRUE
                 );

        unparse_result
            =
            make (   convert_bool,
                     "unparse_result",
                     "TRUE to have read-eval-print-loop unparse expression result to stdout",
                     TRUE
                 );

        support_smlnj_antiquotes
            =
            make (   convert_bool,
                     "support_smlnj_antiquotes",
                     "whether (anti-)quotations are recognized",
                     FALSE
                 );
    };
end;








Comments and suggestions to: bugs@mythryl.org

PreviousUpNext