private AST NodeFactor(bool isFirstNode) { AST nodeAST = NodeEntity(isFirstNode); while (currentToken.Type == TokenType.MUL || currentToken.Type == TokenType.DIV || currentToken.Type == TokenType.BCMUL || currentToken.Type == TokenType.BCDIV) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; nodeAST = new BinOpAST(nodeAST, binOpToken, NodeEntity(isFirstNode)); } return(nodeAST); }
private AST NodeEntity(bool isFirstNode) { AST nodeAST = Node(isFirstNode); while (currentToken.Type == TokenType.CARET || currentToken.Type == TokenType.BCPOW) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; nodeAST = new BinOpAST(nodeAST, binOpToken, Node(isFirstNode)); } return(nodeAST); }
private AST NodeExpr(bool isFirstNode) { AST nodeFactorAST = NodeFactor(isFirstNode); while (currentToken.Type == TokenType.PLUS || currentToken.Type == TokenType.MINUS) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; nodeFactorAST = new BinOpAST(nodeFactorAST, binOpToken, NodeFactor(isFirstNode)); } return(nodeFactorAST); }
private AST ValueEntity() { AST valueAST = Value(); while (currentToken.Type == TokenType.CARET || currentToken.Type == TokenType.BCPOW) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; valueAST = new ValBinOpAST(valueAST, binOpToken, Value()); } return(valueAST); }
private AST ValueFactor() { AST valueAST = ValueEntity(); while (currentToken.Type == TokenType.MUL || currentToken.Type == TokenType.DIV || currentToken.Type == TokenType.BCMUL || currentToken.Type == TokenType.BCDIV) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; valueAST = new ValBinOpAST(valueAST, binOpToken, ValueEntity()); } return(valueAST); }
private AST ValueExpr() { AST valueFactorAST = ValueFactor(); while (currentToken.Type == TokenType.PLUS || currentToken.Type == TokenType.MINUS) { OperatorToken binOpToken = Eat(currentToken.Type) as OperatorToken; valueFactorAST = new ValBinOpAST(valueFactorAST, binOpToken, ValueFactor()); } return(valueFactorAST); }
private ChainAST Chain() { AST nodeExprAST = NodeExpr(true); while (currentToken.Type == TokenType.GOTO) { OperatorToken gotoToken = (OperatorToken)currentToken; Eat(TokenType.GOTO); nodeExprAST = new GotoOpAST(nodeExprAST, NodeExpr(false), gotoToken); } return(new ChainAST(nodeExprAST)); }