Ejemplo n.º 1
0
 public SigmaNode(SyntaxNode expression, NumberNode start, NumberNode end, NumberNode increment) : base(SyntaxType.SIGMA)
 {
     this.expression = expression;
     this.start = start;
     this.end = end;
     this.increment = increment;
 }
Ejemplo n.º 2
0
        private void GenerateReturn(SyntaxNode node, ref string expression)
        {
            switch (node.type)
            {
            case SyntaxType.BINARY:
                BinaryNode binaryNode = (BinaryNode)node;
                GenerateReturn(binaryNode.left, ref expression);
                expression += opToString(binaryNode.op);
                GenerateReturn(binaryNode.right, ref expression);
                break;

            case SyntaxType.NUMBER:
                NumberNode num = (NumberNode)node;
                expression += num.value.ToString();
                break;

            case SyntaxType.IDENTIFIER:
                IdentifierNode identifier = (IdentifierNode)node;
                expression += identifier.identifier;
                break;

            default:
                throw new Exception("Unexpected Node");
            }
        }
Ejemplo n.º 3
0
        private string GenerateNumber(NumberNode node, List <Instruction> instructions)
        {
            string r = GetRegister();

            instructions.Add(new MoveInstruction(node.value.ToString(), r));
            return(r);
        }
Ejemplo n.º 4
0
        private SyntaxNode ReadSigma()
        {
            SyntaxNode expression = ReadExpression();
            NumberNode start      = new NumberNode("0");
            NumberNode end        = new NumberNode("-1");
            NumberNode increment  = new NumberNode("1");

            if (tokenStream.PeekToken().type == TokenType.NUMBER)
            {
                Token token = tokenStream.ReadToken();
                start = new NumberNode(token.data);
            }
            if (tokenStream.PeekToken().type == TokenType.NUMBER)
            {
                Token token = tokenStream.ReadToken();
                end = new NumberNode(token.data);
            }
            if (tokenStream.PeekToken().type == TokenType.NUMBER)
            {
                Token token = tokenStream.ReadToken();
                increment = new NumberNode(token.data);
            }
            return(new SigmaNode(expression, start, end, increment));
        }
Ejemplo n.º 5
0
 private SyntaxNode BindNumber(NumberNode node)
 {
     return(node);
 }