]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Delete macro helper classes and disabled macro expansion
authorMike D. Lowis <mike@mdlowis.com>
Sat, 3 Mar 2012 18:33:16 +0000 (13:33 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Sat, 3 Mar 2012 18:33:16 +0000 (13:33 -0500)
source/dlparser/dlparser.cpp
source/dlparser/dlparser.h
source/dlparser/macro/macro.cpp [deleted file]
source/dlparser/macro/macro.h [deleted file]
source/dlparser/macro/param.cpp [deleted file]
source/dlparser/macro/param.h [deleted file]
source/visitors/macroapplication/macroapplication.cpp [deleted file]
source/visitors/macroapplication/macroapplication.h [deleted file]

index 90d4470b4795e6b919114513a9c8511373b1c5b0..fbb4b6088e6c48b8bdbbba391d9845b15b8421d8 100644 (file)
@@ -29,31 +29,6 @@ bool DLParser::isMacro( Token& token )
     return ret;
 }
 
-AST* DLParser::parseMacroParam(Param* param)
-{
-    AST* ret = NULL;
-    switch( param->type() )
-    {
-        case ExpTyp:
-            ret = LogicalExpr();
-            break;
-
-        case BlockTyp:
-            ret = FuncLiteral();
-            break;
-
-        default:
-            Token& tok = lookaheadToken(1);
-            ostringstream oss;
-            oss << "Expected macro parameter type. Expected " << param->type() << ", received " << tok.type() << ".";
-            Exception ex( tok.line(), tok.column() );
-            ex.setMessage(oss.str());
-            throw ex;
-            break;
-    }
-    return ret;
-}
-
 bool DLParser::speculate_GroupExpr(void)
 {
     AST* throw_away = NULL;
@@ -336,22 +311,6 @@ AST* DLParser::MacroDefinition(void)
     return _new AST(MACRO);
 }
 
-AST* DLParser::MacroExpansion(void)
-{
-    AST* ret = NULL;
-    Macro* cur_macro = macros[ lookaheadToken(1).text() ];
-    list<Param*>::const_iterator it = cur_macro->params().begin();
-
-    consume();
-    for(; it != cur_macro->params().end(); it++)
-    {
-        (*it)->setValue( parseMacroParam( *it ) );
-    }
-    ret = cur_macro->apply();
-
-    return ret;
-}
-
 // MacroPatternList = MacroPattern (',' MacroPattern)*
 AST* DLParser::MacroPatternList(void)
 {
@@ -381,15 +340,6 @@ AST* DLParser::MacroPattern(void)
     match(SEP);
     ret = _new AST(PATT, 2, ret, LogicalExpr());
 
-    //AST* ret = _new AST( ID, lookaheadToken(1).text() );
-    //consume();
-    //if( lookaheadType(1) == SEP )
-    //{
-    //    match(SEP);
-    //    AST* type = _new AST( ID, lookaheadToken(1).text() );
-    //    consume();
-    //    ret = _new AST(SEP, 2, ret, type);
-    //}
     return ret;
 }
 
index 96ab7d15e904b73ba8a5a8d459cb1ca385de975f..5a0b66777c6a0f5159a2c2153019b000af139571 100644 (file)
@@ -4,7 +4,8 @@
 #include <map>
 #include "btparser.h"
 #include "dllexer.h"
-#include "macro.h"
+
+class Macro{};
 
 class DLParser : public BTParser
 {
@@ -15,7 +16,6 @@ class DLParser : public BTParser
         ~DLParser();
         AST* parse(void);
         bool isMacro(Token& token);
-        AST* parseMacroParam(Param* param);
         bool speculate_GroupExpr(void);
 
         /**********************************************************************
@@ -92,7 +92,6 @@ class DLParser : public BTParser
 
         // Macro Rules
         AST* MacroDefinition(void);
-        AST* MacroExpansion(void);
         AST* MacroPatternList(void);
         AST* MacroPattern(void);
 
diff --git a/source/dlparser/macro/macro.cpp b/source/dlparser/macro/macro.cpp
deleted file mode 100644 (file)
index a01f804..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "macro.h"
-#include "macroapplication.h"
-#include "cork.h"
-
-using namespace std;
-
-Macro::Macro(AST* macro_def)
-{
-    list<AST*>::iterator it = macro_def->children()->begin();
-
-    // Set Name
-    macro_name = (*it++)->text();
-
-    // Set Body
-    setUpParamList( *it++ );
-
-    // Set Params
-    macro_body = (*it++)->clone();
-
-}
-
-Macro::~Macro()
-{
-
-    std::list<Param*>::iterator iter;
-    for (iter = macro_params.begin(); iter != macro_params.end(); ++iter) {
-        delete *iter;
-    }
-    delete macro_body;
-}
-
-const std::string& Macro::name(void)
-{
-    return macro_name;
-}
-
-const std::list<Param*>& Macro::params(void)
-{
-    return macro_params;
-}
-
-AST* Macro::apply(void)
-{
-    MacroApplication application(macro_body->clone(), macro_params);
-    application.visit();
-    return application.getAST()->clone();
-}
-
-void Macro::setUpParamList( AST* param_tree )
-{
-    list<AST*>::iterator it = param_tree->children()->begin();
-    for(; it != param_tree->children()->end(); it++)
-    {
-        macro_params.push_back( _new Param( *it ) );
-    }
-}
-
diff --git a/source/dlparser/macro/macro.h b/source/dlparser/macro/macro.h
deleted file mode 100644 (file)
index 8c73c3f..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef MACRO_H
-#define MACRO_H
-
-#include <string>
-#include <list>
-#include "param.h"
-#include "ast.h"
-
-class Macro
-{
-    private:
-        std::string macro_name;
-        std::list<Param*> macro_params;
-        AST* macro_body;
-
-        void setUpParamList( AST* param_tree );
-    public:
-        Macro(AST* macro_def);
-        ~Macro();
-
-        const std::string& name(void);
-        const std::list<Param*>& params(void);
-        AST* apply(void);
-};
-
-#endif
diff --git a/source/dlparser/macro/param.cpp b/source/dlparser/macro/param.cpp
deleted file mode 100644 (file)
index 367c118..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "param.h"
-
-Param::Param(AST* param_def)
-{
-    int children = param_def->children()->size();
-    if( children == 0 )
-    {
-        param_name = param_def->text();
-    }
-    else if( children == 2)
-    {
-        param_name = param_def->children()->front()->text();
-        setType( param_def->children()->front()->text() );
-    }
-    else
-    {
-        // Throw
-    }
-}
-
-Param::~Param()
-{
-    if( param_value != NULL )
-    {
-        delete param_value;
-    }
-}
-
-std::string Param::name(void)
-{
-    return param_name;
-}
-
-ParamType_T Param::type(void)
-{
-    return param_type;
-}
-
-AST* Param::value(void)
-{
-    return param_value;
-}
-
-void Param::setValue(AST* val)
-{
-    param_value = val;
-}
-
-void Param::setType( const std::string& type_string )
-{
-    if ( type_string.compare("Block") == 0 )
-    {
-        param_type = BlockTyp;
-    }
-    else
-    {
-        param_type = ExpTyp;
-    }
-}
-
diff --git a/source/dlparser/macro/param.h b/source/dlparser/macro/param.h
deleted file mode 100644 (file)
index b6787ca..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PARAM
-#define PARAM
-
-#include <string>
-#include "ast.h"
-
-typedef enum {
-    ExpTyp,
-    BlockTyp
-} ParamType_T;
-
-class Param
-{
-    private:
-        std::string param_name;
-        ParamType_T param_type;
-        AST* param_value;
-
-        void setType( const std::string& type_string );
-
-    public:
-        Param(AST* param_def);
-        ~Param();
-
-        std::string name(void);
-        ParamType_T type(void);
-        AST* value(void);
-        void setValue(AST* val);
-};
-
-#endif
diff --git a/source/visitors/macroapplication/macroapplication.cpp b/source/visitors/macroapplication/macroapplication.cpp
deleted file mode 100644 (file)
index 5eefc0a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "macroapplication.h"
-#include "dllexer.h"
-
-using namespace std;
-
-Param* MacroApplication::getParamByName(std::string name)
-{
-    Param* ret = NULL;
-    std::list<Param*>::iterator it = macro_params.begin();
-    for(; it != macro_params.end(); it++)
-    {
-        if( (*it)->name().compare( name ) == 0)
-        {
-            ret = *it;
-            break;
-        }
-    }
-    return ret;
-}
-
-AST* MacroApplication::getAST(void)
-{
-    return mod_ast;
-}
-
-void MacroApplication::beforeVisit(AST* cur, int depth)
-{
-}
-
-void MacroApplication::afterVisit(AST* cur, int depth)
-{
-}
-
-void MacroApplication::beforeChildren(AST* cur, int depth)
-{
-    if(cur->type() == ID)
-    {
-        Param* param = getParamByName( cur->text() );
-        if( param != NULL )
-        {
-            (*cur) = *(param->value());
-        }
-    }
-}
-
-void MacroApplication::afterChildren(AST* cur, int depth)
-{
-}
-
-void MacroApplication::beforeChild(AST* cur, int depth)
-{
-}
-
-void MacroApplication::afterChild(AST* cur, int depth)
-{
-}
-
diff --git a/source/visitors/macroapplication/macroapplication.h b/source/visitors/macroapplication/macroapplication.h
deleted file mode 100644 (file)
index dac41c9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef MacroApplication_H
-#define MacroApplication_H
-
-#include "ivisitor.h"
-#include <iostream>
-#include <sstream>
-#include "param.h"
-
-class MacroApplication : public IVisitor {
-    protected:
-        AST* mod_ast;
-        std::ostringstream stream;
-        std::list<Param*> macro_params;
-    public:
-        MacroApplication(AST* root,std::list<Param*>& params) : IVisitor(root), mod_ast(root), macro_params(params) {};
-        Param* getParamByName(std::string name);
-        AST* getAST(void);
-    private:
-        void beforeVisit(AST* cur, int depth);
-        void afterVisit(AST* cur, int depth);
-        void beforeChildren(AST* cur, int depth);
-        void afterChildren(AST* cur, int depth);
-        void beforeChild(AST* cur, int depth);
-        void afterChild(AST* cur, int depth);
-};
-
-#endif