Skip to content

Commit

Permalink
Merge branch 'vardec_varass_dependency' into feature/multi_module
Browse files Browse the repository at this point in the history
  • Loading branch information
deavmi committed Mar 18, 2024
2 parents 07be57a + 7a2ea96 commit 2537005
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
16 changes: 12 additions & 4 deletions source/tlang/compiler/parsing/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,12 @@ public final class Parser
/* If it is a type */
if (symbolType == SymbolType.IDENT_TYPE)
{
/* Might be a function, might be a variable, or assignment */
structMember = parseName();
/* Might be a function definition or variable declaration */
structMember = parseTypedDeclaration();

/* Should have a semi-colon and consume it */
expect(SymbolType.SEMICOLON, lexer.getCurrentToken());
lexer.nextToken();
}
/* If it is an accessor */
else if (isAccessor(lexer.getCurrentToken()))
Expand Down Expand Up @@ -1890,8 +1894,12 @@ public final class Parser
/* If it is a type */
if (symbolType == SymbolType.IDENT_TYPE)
{
/* Might be a function, might be a variable, or assignment */
structMember = parseName();
/* Might be a function definition or variable declaration */
structMember = parseTypedDeclaration();

/* Should have a semi-colon and consume it */
expect(SymbolType.SEMICOLON, lexer.getCurrentToken());
lexer.nextToken();
}
/* If it is a class */
else if(symbolType == SymbolType.CLASS)
Expand Down
26 changes: 26 additions & 0 deletions source/tlang/compiler/symbols/containers.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,33 @@ public Statement[] weightReorder(Statement[] statements)
// AND MCloneable
public interface Container : MStatementSearchable, MStatementReplaceable
{
/**
* Appends the given statement to
* this container's body
*
* Params:
* statement = the `Statement`
* to add
*/
public void addStatement(Statement statement);

/**
* Appends the list of statemnets
* (in order) to this container's
* body
*
* Params:
* statements = the `Statement[]`
* to add
*/
public void addStatements(Statement[] statements);

/**
* Returns the body of this
* container
*
* Returns: a `Statement[]`
*/
public Statement[] getStatements();
}

Expand Down Expand Up @@ -93,6 +116,7 @@ public class Module : Entity, Container

public Statement[] getStatements()
{
// TODO: Holy naai this is expensive
return weightReorder(statements);
}

Expand Down Expand Up @@ -204,6 +228,7 @@ public class Struct : Type, Container, MCloneable

public Statement[] getStatements()
{
// TODO: Holy naai this is expensive
return weightReorder(statements);
}

Expand Down Expand Up @@ -369,6 +394,7 @@ public class Clazz : Type, Container

public Statement[] getStatements()
{
// TODO: Holy naai this is expensive
return weightReorder(statements);
}

Expand Down

0 comments on commit 2537005

Please sign in to comment.