diff --git a/source/fnc/treegen/ast_types.d b/source/fnc/treegen/ast_types.d index d6293f2..e04f652 100644 --- a/source/fnc/treegen/ast_types.d +++ b/source/fnc/treegen/ast_types.d @@ -240,8 +240,9 @@ class AstNode AstNode voidableType; } static AstNode VOID_NAMED_UNIT(){ - AstNode voidNamedUnit = new AstNode; + AstNode voidNamedUnit = new AstNode(); voidNamedUnit.action = AstAction.NamedUnit; + import fnc.tokenizer.tokens : makeUnicodeString; voidNamedUnit.namedUnit = NamedUnit(["void".makeUnicodeString]); return voidNamedUnit; } diff --git a/source/fnc/treegen/scope_parser.d b/source/fnc/treegen/scope_parser.d index 382a905..20ebc2e 100644 --- a/source/fnc/treegen/scope_parser.d +++ b/source/fnc/treegen/scope_parser.d @@ -307,7 +307,9 @@ LineVarietyTestResult parseLine(const(VarietyTestPair[]) scopeParseMethod, Token auto nodes = lineVariety.tokenMatches[DECLARATION_EXPRESSION] .assertAs(TokenGrepMethod.Glob) .tokens.expressionNodeFromTokens(); - + lineVariety.tokenMatches[DECLARATION_EXPRESSION] + .assertAs(TokenGrepMethod.Glob) + .tokens.writeln; if (nodes.length != 1) throw new SyntaxError( "Expression node tree could not be parsed properly (Not reducable into single node)", @@ -321,6 +323,9 @@ LineVarietyTestResult parseLine(const(VarietyTestPair[]) scopeParseMethod, Token parent.instructions ~= assignment; break; case LineVariety.TaggedUntypedItem: + size_t endingIndex = index + lineVariety.length; + scope (exit) + index = endingIndex; NamedUnit name = lineVariety.tokenMatches[0].assertAs(TokenGrepMethod.NamedUnit).name; parent.declaredVariables ~= DeclaredVariable(name, AstNode.VOID_NAMED_UNIT); break; diff --git a/source/fnc/treegen/utils.d b/source/fnc/treegen/utils.d index 21cf500..4b0c9cc 100644 --- a/source/fnc/treegen/utils.d +++ b/source/fnc/treegen/utils.d @@ -9,33 +9,31 @@ NamedUnit genNamedUnit(Token[] tokens, ref size_t index) { dchar[][] nameData = new dchar[][0]; // NamedUnit ret = NamedUnit(new dchar[][]); - Nullable!Token tokenNullable = tokens.nextNonWhiteToken(index); - Token token; - - // An attempt to generate a name at an EOF - if (tokenNullable.ptr == null) - return NamedUnit(nameData); - index--; - token = tokenNullable; - - while (token.tokenVariety == TokenType.Letter || token.tokenVariety == TokenType.Number || token.tokenVariety == TokenType - .Period) + bool hasLastPeriod = true; + while (1) { - - if (token.tokenVariety != TokenType.Period) + Nullable!Token tokenNullable = tokens.nextNonWhiteToken(index); + if (tokenNullable == null) + return NamedUnit(nameData); + Token token = tokenNullable; + if (token.tokenVariety == TokenType.Period){ + hasLastPeriod = true; + continue; + } + if (token.tokenVariety == TokenType.Letter) { + if (!hasLastPeriod) + { + index--; + return NamedUnit(nameData); + } nameData ~= token.value; + hasLastPeriod = false; + continue; } - - Nullable!Token tokenNullable2 = tokens.nextToken(index); - - // We hit an EOF - if (!tokenNullable2.ptr) - return NamedUnit(nameData); - token = tokenNullable2; - + index--; + return NamedUnit(nameData); } - return NamedUnit(nameData); - + } diff --git a/source/main.d b/source/main.d index de7dcd5..0036e48 100644 --- a/source/main.d +++ b/source/main.d @@ -64,9 +64,10 @@ void main() private tagged Element{ kind; idk; + int anElmentWithNumber; } int main(){ - return => add(y : 1, x : 1, offset : 3); + const Element e = Element.idk; } ");