corrected implementation of unary operators

This commit is contained in:
Clemens-Dautermann 2020-08-20 22:37:30 +02:00
parent 202c1d2ca2
commit 07079366b8
6 changed files with 156 additions and 117 deletions

View file

@ -139,22 +139,18 @@ namespace Compiler
{
switch (root.NodeType)
{
case NodeType.ExpressionNode:
if (root is UnaryOperatorNode)
{
Console.WriteLine(indent + root.NodeType + ":" + ((UnaryOperatorNode) root).OperatorType);
}
if (root is ConstantNode)
{
Console.WriteLine(indent + root.NodeType + ":" + ((ConstantNode) root).value);
}
break;
case NodeType.FunctionNode:
Console.WriteLine(indent + root.NodeType + ":" + ((FunctionNode) root).Name);
break;
case NodeType.ProgramNode:
case NodeType.ReturnStatementNode:
case NodeType.ConstantNode:
Console.WriteLine(indent + root.NodeType + ":" + ((ConstantNode) root).value);
break;
case NodeType.UnaryOperatorNode:
Console.WriteLine(indent + root.NodeType + ":" + ((UnaryOperatorNode) root).OperatorType);
break;
default:
Console.WriteLine(indent + root.NodeType);
break;
}