Skip to content

Commit

Permalink
Parser
Browse files Browse the repository at this point in the history
- Removed this print out
- Added more recursive painting of various dofferent AST nodes
  • Loading branch information
deavmi committed May 6, 2024
1 parent fa2f638 commit ca1c51d
Showing 1 changed file with 52 additions and 2 deletions.
54 changes: 52 additions & 2 deletions source/tlang/compiler/parsing/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -2483,6 +2483,48 @@ public final class Parser

parentToContainer(container, [binOpExp.getLeftExpression(), binOpExp.getRightExpression()]);
}
/**
* If we have an `UnaryOperatorExpression`
* then we want to parent its inner
* expression
*/
else if(cast(UnaryOperatorExpression)statement)
{
UnaryOperatorExpression unaryOp = cast(UnaryOperatorExpression)statement;
Expression opExpr = unaryOp.getExpression();

parentToContainer(container, [opExpr]);
}
/**
* If we have an `ArrayIndex` then
* we will want to parent its inner
* expression which is what the
* index itself is formed out of.
*
* We will also want to parent the
* expression being indexed itself.
*/
else if(cast(ArrayIndex)statement)
{
ArrayIndex indexOp = cast(ArrayIndex)statement;
Expression indexedExpr = indexOp.getIndexed();
Expression indexExpr = indexOp.getIndex();

parentToContainer(container, [indexedExpr, indexExpr]);
}
/**
* If we have an `ArrayAssignment` then
* we will want to parent its inner
* index-expression
*/
else if(cast(ArrayAssignment)statement)
{
ArrayAssignment arrAss = cast(ArrayAssignment)statement;
Expression indexExpr = arrAss.getArrayLeft();
Expression assExpr = arrAss.getAssignmentExpression();

parentToContainer(container, [indexExpr, assExpr]);
}
/**
* If we have a `VariableAssignmentStdAlone`
* then we must parent its expression
Expand Down Expand Up @@ -2521,6 +2563,16 @@ public final class Parser
Expression[] actualArguments = funcCall.getCallArguments();
parentToContainer(container, cast(Statement[])actualArguments);
}
/**
* If we have a `CastedExpression`
*/
else if(cast(CastedExpression)statement)
{
CastedExpression castExpr = cast(CastedExpression)statement;

Expression toCast = castExpr.getEmbeddedExpression();
parentToContainer(container, [toCast]);
}
/**
* If we have a `ReturnStmt`
* then we must process its
Expand Down Expand Up @@ -4176,7 +4228,6 @@ unittest
}
catch(TError e)
{
ERROR(e);
assert(false);
}
}
Expand Down Expand Up @@ -4272,7 +4323,6 @@ public int i = 2;
}
catch(TError e)
{
stderr.writeln(e);
assert(false);
}

Expand Down

0 comments on commit ca1c51d

Please sign in to comment.