Save state before re-write of RegEx.

This commit is contained in:
Nathan Braswell
2014-01-07 13:14:58 -05:00
parent 82df9b1592
commit 0297f29dcd
13 changed files with 139 additions and 57 deletions

View File

@@ -5,28 +5,29 @@
#include <map>
#include "Symbol.h"
//Circular dependency
class Type;
#include "Type.h"
#ifndef NULL
#define NULL 0
#endif
enum ASTType {undef, translation_unit, interpreter_directive, import, identifier,
function, code_block,
typed_parameter, expression, boolean_expression, statement,
enum ASTType {undef, translation_unit, interpreter_directive, import, identifier, type_def,
function, code_block, typed_parameter, expression, boolean_expression, statement,
if_statement, while_loop, for_loop, return_statement, assignment_statement, declaration_statement,
if_comp, simple_passthrough, function_call, value};
class ASTData {
public:
ASTData();
ASTData(ASTType type, Type valueType = Type());
ASTData(ASTType type, Symbol symbol, Type valueType = Type());
ASTData(ASTType type, Type *valueType = NULL);
ASTData(ASTType type, Symbol symbol, Type *valueType = NULL);
~ASTData();
std::string toString();
static std::string ASTTypeToString(ASTType type);
ASTType type;
Type valueType;
Type* valueType;
Symbol symbol;
std::map<std::string, NodeTree<ASTData>*> scope;
private:

View File

@@ -4,6 +4,7 @@
#include <set>
#include <map>
#include "Type.h"
#include "ASTData.h"
#include "NodeTransformation.h"
#include "Importer.h"
@@ -18,6 +19,7 @@ class ASTTransformation: public NodeTransformation<Symbol,ASTData> {
NodeTree<ASTData>* transform(NodeTree<Symbol>* from, NodeTree<ASTData>* scope);
std::string concatSymbolTree(NodeTree<Symbol>* root);
NodeTree<ASTData>* scopeLookup(NodeTree<ASTData>* scope, std::string lookup);
Type* typeFromString(std::string type, NodeTree<ASTData>* scope);
private:
Importer * importer;
};

View File

@@ -18,7 +18,7 @@ class CGenerator {
~CGenerator();
void generateCompSet(std::map<std::string, NodeTree<ASTData>*> ASTs, std::string outputName);
std::string generate(NodeTree<ASTData>* from);
static std::string ValueTypeToCType(Type type);
static std::string ValueTypeToCType(Type *type);
std::string generatorString;
private:

View File

@@ -8,6 +8,9 @@
#include <string>
#include <iostream>
//Circular dependency
class ASTData;
#include "ASTData.h"
#include "util.h"
enum ValueType {none, void_type, boolean, integer, floating, double_percision, character };
@@ -18,10 +21,13 @@ class Type {
Type();
Type(ValueType typeIn, int indirectionIn);
Type(ValueType typeIn);
Type(std::string typeIn);
Type(NodeTree<ASTData>* typeDefinitionIn);
Type(NodeTree<ASTData>* typeDefinitionIn, int indirectionIn);
Type(ValueType typeIn, NodeTree<ASTData>* typeDefinitionIn, int indirectionIn);
~Type();
std::string toString();
ValueType baseType;
NodeTree<ASTData>* typeDefinition;
int indirection;
private:
};