diff --git a/source/tlang/compiler/compiler.d b/source/tlang/compiler/compiler.d index e96f7fa..6d5ce39 100644 --- a/source/tlang/compiler/compiler.d +++ b/source/tlang/compiler/compiler.d @@ -4,7 +4,7 @@ import gogga; import std.conv : to; import compiler.lexer; import std.stdio : File; -import compiler.parser; +import compiler.parsing.core; import compiler.symbols.check; import compiler.symbols.data; import compiler.typecheck.core; diff --git a/source/tlang/compiler/parser.d b/source/tlang/compiler/parsing/core.d similarity index 99% rename from source/tlang/compiler/parser.d rename to source/tlang/compiler/parsing/core.d index e79c383..b1d7d23 100644 --- a/source/tlang/compiler/parser.d +++ b/source/tlang/compiler/parsing/core.d @@ -1,4 +1,4 @@ -module compiler.parser; +module compiler.parsing.core; import gogga; import std.conv : to; diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index d1a0a11..28f4e91 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -6,7 +6,7 @@ import std.conv : to; import std.string; import std.stdio; import gogga; -import compiler.parser; +import compiler.parsing.core; /** * The Parser only makes sure syntax @@ -149,6 +149,15 @@ public final class TypeChecker Variable variable = cast(Variable)statement; gprintln("Declaring variable"~variable.getName()); + /** + * To check if a name is taken we check if the current one equals the + * first match (if so, then declare, if not, then taken) + */ + if(getEntity(c, variable.getName()) != variable) + { + Parser.expect("Duplicate name tried to be declared"); + } + /* Check if this variable has an expression, if so check that */ if(variable.getAssignment()) { @@ -162,25 +171,12 @@ public final class TypeChecker Parser.expect("Expression type fetch failed: "~variable.getName()); } gprintln("ExpressionTYpe in VarAssign: "~type); + + } - /* If not then go ahead and attempt to declare it */ - else - { - /** - * To check if a name is taken we check if the current one equals the - * first match (if so, then declare, if not, then taken) - */ - if(getEntity(c, variable.getName()) != variable) - { - import compiler.parser; - Parser.expect("Duplicate name tried to be declared"); - } - else - { - markEntity(variable); - // declareName(path~variable.getName()); - } - } + + /* Set the variable as declared */ + markEntity(variable); } } } @@ -399,7 +395,6 @@ public final class TypeChecker private bool checkDuplicateTopLevel() { import misc.utils; - import compiler.parser : Parser; /* List of names travsersed so far */ string[] names; @@ -429,7 +424,7 @@ unittest import std.file; import std.stdio; import compiler.lexer; - import compiler.parser; + import compiler.parsing.core; // isUnitTest = true;