/*primary-expression: | "new" instance-expression primary-expression-p | literal primary-expression-p | identifier primary-expression-p | '(' expression ')' primary-expression-p | "this" primary-expression-p | "base" primary-expression-p | "null" | type primary-expression-p*/ private InlineExpressionNode primary_expression() { printIfDebug("primary_expression"); if (pass(TokenType.RW_NEW)) { var NewToken = token; consumeToken(); var instance = instance_expression(); var inline = new InlineExpressionNode(instance, NewToken); primary_expression_p(ref inline); return(inline); } else if (pass(literalOptions)) { var literalToken = token; consumeToken(); PrimaryExpressionNode literal = null; if (literalToken.type == TokenType.LIT_INT) { literal = new LiteralIntNode(literalToken.lexeme, literalToken); } else if (literalToken.type == TokenType.LIT_FLOAT) { literal = new LiteralFloatNode(literalToken.lexeme, literalToken); } else if (literalToken.type == TokenType.LIT_BOOL) { literal = new LiteralBoolNode(literalToken.lexeme, literalToken); } else if (literalToken.type == TokenType.LIT_CHAR) { literal = new LiteralCharNode(literalToken.lexeme, literalToken); } else if (literalToken.type == TokenType.LIT_STRING) { literal = new LiteralStringNode(literalToken.lexeme, literalToken); } var inline = new InlineExpressionNode(literal, literalToken); primary_expression_p(ref inline); return(inline); } else if (pass(TokenType.ID)) { var identifier = new IdNode(token.lexeme, token); consumeToken(); var inline = new InlineExpressionNode(identifier, identifier.token); primary_expression_p(ref inline); return(inline); } else if (pass(TokenType.PUNT_PAREN_OPEN)) { var parentizedToken = token; consumeToken(); var exp = expression(); if (!pass(TokenType.PUNT_PAREN_CLOSE)) { throwError(") expected"); } consumeToken(); var groupedExp = new GroupedExpressionNode(exp, exp.token); var inline = new InlineExpressionNode(groupedExp, parentizedToken); primary_expression_p(ref inline); return(inline); } else if (pass(TokenType.RW_THIS)) { var thisToken = token; consumeToken(); var thisExp = new ThisReferenceAccsessNode(thisToken); var inline = new InlineExpressionNode(thisExp, thisToken); primary_expression_p(ref inline); return(inline); } else if (pass(TokenType.RW_BASE)) { var baseToken = token; consumeToken(); var baseExp = new BaseReferenceAccessNode(baseToken); var inline = new InlineExpressionNode(baseExp, baseToken); primary_expression_p(ref inline); return(inline); } else if (pass(TokenType.RW_NULL)) { var nullToken = token; consumeToken(); var nullExp = new NullExpressionNode(nullToken); var inline = new InlineExpressionNode(nullExp, nullToken); // primary_expression_p(ref inline); return(inline); } else if (pass(typesOptions)) { var type = types(); var inline = new InlineExpressionNode(new IdNode(type.ToString(), type.token), type.token); primary_expression_p(ref inline); return(inline); } else { throwError("new, literal, identifier, '(' or \"this\" expected"); } return(null); }
public void PushLoop(PrimaryExpressionNode loop) { _loops.Push(loop); }