PreviousUpNext

15.4.181  src/lib/c-kit/src/ast/extensions/c/cnv-ext.pkg

# cnv-ext.pkg

# Compiled by:
#     src/lib/c-kit/src/ast/ast.sublib

package   cnv_ext
: (weak)  Cnv_Ext               # Cnv_Ext       is from   src/lib/c-kit/src/ast/cnv-ext.api
{

    Core_Conversion_Funs = 
         {
          state_funs:  state::State_Funs,
          munge_ty_decr: ((raw_syntax::Ctype,parse_tree::Declarator) ->(raw_syntax::Ctype, Null_Or( String )) ),

          cnv_type:  (Bool,parse_tree::Decltype) -> (raw_syntax::Ctype,raw_syntax::Storage_Ilk),
          cnv_expression: parse_tree::Expression -> (raw_syntax::Ctype, raw_syntax::Expression),
          cnv_statement:  parse_tree::Statement -> raw_syntax::Statement,
          cnv_external_decl: parse_tree::External_Decl -> List( raw_syntax::External_Decl ),

          wrap_expr: ((raw_syntax::Ctype,raw_syntax::Core_Expression) -> (raw_syntax::Ctype,raw_syntax::Expression)),
          wrap_statement: raw_syntax::Core_Statement -> raw_syntax::Statement,
          wrap_decl: raw_syntax::Core_External_Decl -> raw_syntax::External_Decl
          };

    Expression_Ext
       =
       parse_tree_ext::Expression_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    Statement_Ext
       =
       parse_tree_ext::Statement_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    External_Decl_Ext
       =
       parse_tree_ext::External_Decl_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    Specifier_Ext
       =
       parse_tree_ext::Specifier_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    Declarator_Ext
       =
       parse_tree_ext::Declarator_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    Declaration_Ext
       =
       parse_tree_ext::Declaration_Ext(

           parse_tree::Specifier,
           parse_tree::Declarator,
           parse_tree::Ctype,
           parse_tree::Decltype,
           parse_tree::Operator,
           parse_tree::Expression,
           parse_tree::Statement
       );


    Extension_Funs
       = 
       { cnvexp: Expression_Ext -> (raw_syntax::Ctype, raw_syntax::Expression),
        cnvstat: Statement_Ext -> raw_syntax::Statement,
        cnvbinop: { binop: parse_tree_ext::Operator_Ext, arg1expr: parse_tree::Expression, arg2expr: parse_tree::Expression }
                  -> (raw_syntax::Ctype, raw_syntax::Expression),
        cnvunop: { unop: parse_tree_ext::Operator_Ext, arg_expr: parse_tree::Expression }
                  -> (raw_syntax::Ctype, raw_syntax::Expression),
        cnvexternal_decl: External_Decl_Ext -> List( raw_syntax::External_Decl ),
        cnvspecifier: { is_shadow: Bool, rest:  List( parse_tree::Specifier ) } 
                  -> Specifier_Ext
                  -> raw_syntax::Ctype,
        cnvdeclarator: (raw_syntax::Ctype, Declarator_Ext) -> (raw_syntax::Ctype, Null_Or( String )),
        cnvdeclaration: Declaration_Ext -> List( raw_syntax::Declaration ) };

    exception CONVERT_EXTENSION  String;

    fun cnvexp _ = raise exception (CONVERT_EXTENSION "No proper extensions to expressions");

    fun cnvstat _ = raise exception (CONVERT_EXTENSION "No proper extensions to statements");

    fun cnvbinop _ = raise exception (CONVERT_EXTENSION "No proper extensions to binops");

    fun cnvunop _ =  raise exception (CONVERT_EXTENSION "No proper extensions to unnops");

    fun cnvexternal_decl _ = raise exception (CONVERT_EXTENSION "No proper extensions to external decls");

    fun cnvspecifier _ _ = raise exception (CONVERT_EXTENSION "No proper extensions to specifiers");

    fun cnvdeclarator _ = raise exception (CONVERT_EXTENSION "No proper extensions to declarators");

    fun cnvdeclaration _ = raise exception (CONVERT_EXTENSION "No proper extensions to declarations");

    fun make_extension_funs _ = { cnvexp => cnvexp,
                               cnvstat => cnvstat,
                               cnvbinop => cnvbinop,
                               cnvunop => cnvunop,
                               cnvexternal_decl => cnvexternal_decl,
                               cnvspecifier => cnvspecifier,
                               cnvdeclarator => cnvdeclarator,
                               cnvdeclaration => cnvdeclaration };

    # prototypical use of makeExtensionsFuns for non-trival extensions:
    # 
    # fun makeExtensions { stateFuns, mungeTyDecr, cnvType, cnvExpression, cnvStatement, cnvExternalDecl,
    #                     wrapEXPR, wrapSTMT, wrapDECL } =
    #   let 
    #       fun raiseError ... #  local helper function 
    #       my ....   #  local helper function 
    #        ... etc ... #  more local helper functions 
    #
    #       fun CNVExp args = ..
    #       fun CNVStat args = ..
    #        ... etc ...
    #   in { CNVExp = CNVExp, CNVStat = CNVStat, ....}
    #   end


};

/****************

package convert_extension:  CNVEXT

pkg

    type cnv = { stateFuns: state::stateFuns,
                cnvType: bool * ParseTree::decltype -> raw_syntax::ctype * raw_syntax::storageIlk,
                mungeTyDecr: raw_syntax::ctype * ParseTree::declarator -> raw_syntax::ctype * Null_Or( string ),
                cnvExpression: ParseTree::expression -> raw_syntax::ctype * raw_syntax::expression,
                cnvStatement: ParseTree::statement -> raw_syntax::statement }

    exception CONVERT_EXTENSION of string

    intType = raw_syntax::Numeric (raw_syntax::NONSATURATE, raw_syntax::WHOLENUM, raw_syntax::SIGNED, raw_syntax::INT)

    fun CNVExp _ _ = raise (CONVERT_EXTENSION "No proper extensions to expressions")

    fun CNVStat _ _ = raise (CONVERT_EXTENSION "No proper extensions to statements")

    fun CNVBinop _ _ = raise (CONVERT_EXTENSION "No proper extensions to binops")

    fun CNVUnop _ _ =  raise (CONVERT_EXTENSION "No proper extensions to unnops")

    fun CNVExternalDecl _ _ = raise (CONVERT_EXTENSION "No proper extensions to external decls")

    fun CNVSpecifier _ _ = raise (CONVERT_EXTENSION "No proper extensions to specifiers")

    fun CNVDeclarator _ _ = raise (CONVERT_EXTENSION "No proper extensions to declarators")

    fun CNVDeclaration _ _ = raise (CONVERT_EXTENSION "No proper extensions to declarations")
end
 ***************/


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext