PreviousUpNext

15.3.17  src/app/makelib/parse/libfile-grammar-actions.api

## libfile-grammar-actions.api -- Semantic actions .lib file syntax grammar.

# Compiled by:
#     src/app/makelib/makelib.sublib


##                   "Computer language design is just
##                    like a stroll in the park.
##
##                   "Jurassic Park, that is."
##
##                                -- Larry Wall in <1994Jun15.074039.2654@netlabs.com>


stipulate
    package ad  =  anchor_dictionary;                           # anchor_dictionary                     is from   src/app/makelib/paths/anchor-dictionary.pkg
    package sm  =  line_number_db;                              # line_number_db                        is from   src/lib/compiler/front/basics/source/line-number-db.pkg
    package ms  =  makelib_state;                               # makelib_state                         is from   src/app/makelib/main/makelib-state.pkg
    package mvi =  makelib_version_intlist;                     # makelib_version_intlist               is from   src/app/makelib/stuff/makelib-version-intlist.pkg
    package lg  =  inter_library_dependency_graph;              # inter_library_dependency_graph        is from   src/app/makelib/depend/inter-library-dependency-graph.pkg
    package sy  =  symbol;                                      # symbol                                is from   src/lib/compiler/front/basics/map/symbol.pkg
herein
    
    api Libfile_Grammar_Actions {
        #
        Source_Code_Region =   sm::Source_Code_Region;

        Cm_Symbol;
        Cm_Ilk;

        Int_Expression;
        Bool_Expression;

        Members;                        #  Still conditional 
        Exports_Symbolset;                      #  Still conditional 

        Tool_Option;
        Tool_Index;

        Plaint_Sink = String -> Void;

        make_tool_index:  Void -> Tool_Index;

        #  Getting elements of primitive types (pathnames and symbols) 

        file_native
            :
            ( String,
              ad::Path_Root,
              Plaint_Sink
            )
            ->
            ad::Dir_Path;

        file_standard
            :
            ms::Makelib_State
            ->
            ( String,
              ad::Path_Root,
              Plaint_Sink
            )
            ->
            ad::Dir_Path;

        cm_version
            :
            ( String,
              Plaint_Sink
            )
            ->
            mvi::Makelib_Version_Intlist;

        cm_symbol:     String -> Cm_Symbol;

        my_package:     String -> sy::Symbol;
        my_api:         String -> sy::Symbol;
        my_g:           String -> sy::Symbol;
        my_generic_api: String -> sy::Symbol;

        ilk:         Cm_Symbol -> Cm_Ilk;

        #  Getting the full analysis for a library/freezefile 

        make_sublibrary
          :
          { path:       ad::File,
            #
            exports: Exports_Symbolset,
            members: Members,
            #
            makelib_state:  ms::Makelib_State,
            this_library:       Null_Or( ad::File ),
            primordial_library: lg::Library
          }
          ->
          lg::Library;


        make_main_library
          :
          { path:                       ad::File,
            #
            exports:                    Exports_Symbolset,
            makelib_version_intlist:    Null_Or( mvi::Makelib_Version_Intlist ),
            #   
            makelib_state:              ms::Makelib_State,
            members:                    Members,
            primordial_library:         lg::Library
          }
          ->
          lg::Library;

        #  Assembling privilege lists: 
 
        #  Constructing member collections: 
        empty_members:  Members;

        make_member
          :
          { makelib_state: ms::Makelib_State,

            recursive_parse
                :
                Null_Or( ad::File )
                ->
                ( ad::File,
                  Null_Or( mvi::Makelib_Version_Intlist )
                , ad::Renamings # MUSTDIE
                )
                ->
                lg::Library,

            load_plugin: ad::Path_Root -> String -> Bool
          }
          ->
          {    name:   String,
               make_path: Void -> ad::Dir_Path,

               library: (ad::File, Source_Code_Region),
               ilk:     Null_Or( Cm_Ilk ),

               tool_options:    Null_Or(  List(  Tool_Option ) ),
               local_index: Tool_Index,

               path_root: ad::Path_Root
          }
          ->
          Members;

        members:  (Members, Members) -> Members;

        guarded_members:  (Bool_Expression, ((Members, Members)), (String -> Void)) -> Members;

        error_member:  (Void -> Void) -> Members;

        #  Constructing symbol sets: 

        exports_symbolset_from_symbol:  (sy::Symbol, Plaint_Sink) -> Exports_Symbolset;

        union_of_exports_symbolsets:         (Exports_Symbolset, Exports_Symbolset) -> Exports_Symbolset;
        difference_of_exports_symbolsets:    (Exports_Symbolset, Exports_Symbolset) -> Exports_Symbolset;
        intersection_of_exports_symbolsets:  (Exports_Symbolset, Exports_Symbolset) -> Exports_Symbolset;


        api_or_pkg_exported_symbols:  (Null_Or( ad::File ), Plaint_Sink) -> Exports_Symbolset;  # NULL: Return set of all symbols exported from all .api and .pkg files in library. THE(file): Only symbols exported by from 'file'.
        sublibrary_exported_symbols:  (Null_Or( ad::File ), Plaint_Sink) -> Exports_Symbolset;

        export_freezefile
           :
           ( ad::File,
             Plaint_Sink,
             { hasoptions:     Bool,
               elab:           Void -> Members,
               this_library:   Null_Or( ad::File )
             }
           )
           ->
           Exports_Symbolset;

        # Constructing export lists:
        #
        empty_exports:            Exports_Symbolset;
        conditional_exports:     (/* if */ Bool_Expression, (/* then */ Exports_Symbolset, /* else */ Exports_Symbolset), Plaint_Sink) -> Exports_Symbolset;
        #
        default_library_exports:  Exports_Symbolset;
        error_export:            (Void -> Void) -> Exports_Symbolset;

        # Groups of operator symbols (to make grammar smaller) 
        #
        Addsym = PLUS  | MINUS;
        Mulsym = TIMES | DIV | MOD;

        Eqsym   = EQ | NE;
        Ineqsym = GT | GE | LT | LE;

    #    type Addsym;
    #
    #    my PLUS:   Addsym;
    #    my MINUS:  Addsym;
    #    
    #    type Mulsym;
    #    my TIMES:  Mulsym;
    #    my DIV:    Mulsym;
    #    my MOD:    Mulsym;
    #
    #    type Eqsym;
    #    my EQ:  Eqsym;
    #    my NE:  Eqsym;
    #
    #    type Ineqsym;
    #    my GT:  Ineqsym;
    #    my GE:  Ineqsym;
    #    my LT:  Ineqsym;
    #    my LE:  Ineqsym;



        #  Arithmetic (number-valued) expression 

        number:  Int -> Int_Expression;

        variable:  ms::Makelib_State -> Cm_Symbol -> Int_Expression;

        add:  (Int_Expression, Addsym, Int_Expression) -> Int_Expression;
        mul:  (Int_Expression, Mulsym, Int_Expression) -> Int_Expression;

        sign:  (Addsym, Int_Expression) -> Int_Expression;

        negate:  Int_Expression -> Int_Expression;



        # Boolean-valued expressions:

        ml_defined:  sy::Symbol -> Bool_Expression;

        is_defined_hostproperty:  ms::Makelib_State -> Cm_Symbol -> Bool_Expression;

        conj:  (Bool_Expression, Bool_Expression) -> Bool_Expression;
        disj:  (Bool_Expression, Bool_Expression) -> Bool_Expression;

        beq:  (Bool_Expression, Eqsym, Bool_Expression) -> Bool_Expression;
        not:   Bool_Expression                          -> Bool_Expression;

        ineq:  (Int_Expression, Ineqsym, Int_Expression) -> Bool_Expression;
        eq:    (Int_Expression,   Eqsym, Int_Expression) -> Bool_Expression;

        # Tool options 
        string:   { name: String,   make_path:     Void -> ad::Dir_Path } -> Tool_Option;
        subopts:  { name: String,   tool_options:  List( Tool_Option )  } -> Tool_Option;
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext