PreviousUpNext

15.4.571  src/lib/compiler/front/parser/raw-syntax/oop-syntax-parser-transform.pkg

## oop-syntax-parser-transform.pkg

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

# For general background see the comments in
#
#     src/lib/compiler/front/parser/raw-syntax/oop-syntax-parser-transform.api


package oop_syntax_parser_transform:   Oop_Syntax_Parser_Transform {            # Oop_Syntax_Parser_Transform   is from   src/lib/compiler/front/parser/raw-syntax/oop-syntax-parser-transform.api

    include raw_syntax;

    fun prepend_dummy_package_references_to_declaration
        (declaration:  Declaration)
        :
        Declaration
        =
        {
            # Prepend two dummy declarations to existing
            # declaration(s) and return the result:
            #
            case declaration
                SEQUENTIAL_DECLARATIONS  declaration_list
                    =>
                    SEQUENTIAL_DECLARATIONS
                        ( [ dummy_package_refs ]
                        @   declaration_list
                        );

                _   =>
                    SEQUENTIAL_DECLARATIONS
                        ( [ dummy_package_refs ]
                        @ [ declaration ]
                        );
            esac
            where
                # Synthesize the raw syntax equivalent to:
                #
                #     package dummy__oop__ref     = oop;
                #     package dummy__object__ref  = object;
                #     package dummy__object2__ref = object2;
                #
                dummy_package_refs
                    =
                    PACKAGE_DECLARATIONS
                      [
                        make_dummy_package_ref ("dummy__oop__ref",    "oop"    ),
                        make_dummy_package_ref ("dummy__object_ref",  "object" ),
                        make_dummy_package_ref ("dummy__object2_ref", "object2")
                      ]
                      where
                          fun make_dummy_package_ref (dummy_name, actual_name)
                              =                                                         # symbol                        is from   src/lib/compiler/front/basics/map/symbol.pkg
                              NAMED_PACKAGE
                                {
                                  name_symbol =>                 ( symbol::make_package_symbol  dummy_name  ),
                                  definition  => PACKAGE_BY_NAME [ symbol::make_package_symbol  actual_name ],

                                  constraint => NO_PACKAGE_CAST,
                                  kind       => PLAIN_PACKAGE
                                };
                      end;
            end;
        };
};



Comments and suggestions to: bugs@mythryl.org

PreviousUpNext