Lines Matching refs:Parser
5 #include "tools/gn/parser.h"
33 // parser is a Pratt parser. The basic idea there is to have the precedences
36 // expressions_ at the top of parser.cc that describes how each token
45 ParserHelper Parser::expressions_[] = {
47 {&Parser::Literal, NULL, -1}, // INTEGER
48 {&Parser::Literal, NULL, -1}, // STRING
49 {&Parser::Literal, NULL, -1}, // TRUE_TOKEN
50 {&Parser::Literal, NULL, -1}, // FALSE_TOKEN
51 {NULL, &Parser::Assignment, PRECEDENCE_ASSIGNMENT}, // EQUAL
52 {NULL, &Parser::BinaryOperator, PRECEDENCE_SUM}, // PLUS
53 {NULL, &Parser::BinaryOperator, PRECEDENCE_SUM}, // MINUS
54 {NULL, &Parser::Assignment, PRECEDENCE_ASSIGNMENT}, // PLUS_EQUALS
55 {NULL, &Parser::Assignment, PRECEDENCE_ASSIGNMENT}, // MINUS_EQUALS
56 {NULL, &Parser::BinaryOperator, PRECEDENCE_EQUALITY}, // EQUAL_EQUAL
57 {NULL, &Parser::BinaryOperator, PRECEDENCE_EQUALITY}, // NOT_EQUAL
58 {NULL, &Parser::BinaryOperator, PRECEDENCE_RELATION}, // LESS_EQUAL
59 {NULL, &Parser::BinaryOperator, PRECEDENCE_RELATION}, // GREATER_EQUAL
60 {NULL, &Parser::BinaryOperator, PRECEDENCE_RELATION}, // LESS_THAN
61 {NULL, &Parser::BinaryOperator, PRECEDENCE_RELATION}, // GREATER_THAN
62 {NULL, &Parser::BinaryOperator, PRECEDENCE_AND}, // BOOLEAN_AND
63 {NULL, &Parser::BinaryOperator, PRECEDENCE_OR}, // BOOLEAN_OR
64 {&Parser::Not, NULL, -1}, // BANG
65 {&Parser::Group, NULL, -1}, // LEFT_PAREN
67 {&Parser::List, &Parser::Subscript, PRECEDENCE_CALL}, // LEFT_BRACKET
73 {&Parser::Name, &Parser::IdentifierOrCall, PRECEDENCE_CALL}, // IDENTIFIER
78 Parser::Parser(const std::vector<Token>& tokens, Err* err)
82 Parser::~Parser() {
86 scoped_ptr<ParseNode> Parser::Parse(const std::vector<Token>& tokens,
88 Parser p(tokens, err);
93 scoped_ptr<ParseNode> Parser::ParseExpression(const std::vector<Token>& tokens,
95 Parser p(tokens, err);
99 bool Parser::IsAssignment(const ParseNode* node) const {
106 bool Parser::IsStatementBreak(Token::Type token_type) const {
119 bool Parser::LookAhead(Token::Type type) {
125 bool Parser::Match(Token::Type type) {
132 Token Parser::Consume(Token::Type type, const char* error_message) {
137 Token Parser::Consume(Token::Type* types,
163 Token Parser::Consume() {
167 scoped_ptr<ParseNode> Parser::ParseExpression() {
171 scoped_ptr<ParseNode> Parser::ParseExpression(int precedence) {
207 scoped_ptr<ParseNode> Parser::Literal(Token token) {
211 scoped_ptr<ParseNode> Parser::Name(Token token) {
215 scoped_ptr<ParseNode> Parser::Group(Token token) {
223 scoped_ptr<ParseNode> Parser::Not(Token token) {
233 scoped_ptr<ParseNode> Parser::List(Token node) {
240 scoped_ptr<ParseNode> Parser::BinaryOperator(scoped_ptr<ParseNode> left,
257 scoped_ptr<ParseNode> Parser::IdentifierOrCall(scoped_ptr<ParseNode> left,
295 scoped_ptr<ParseNode> Parser::Assignment(scoped_ptr<ParseNode> left,
309 scoped_ptr<ParseNode> Parser::Subscript(scoped_ptr<ParseNode> left,
326 scoped_ptr<ListNode> Parser::ParseList(Token::Type stop_before,
354 scoped_ptr<ParseNode> Parser::ParseFile() {
371 scoped_ptr<ParseNode> Parser::ParseStatement() {
392 scoped_ptr<BlockNode> Parser::ParseBlock() {
414 scoped_ptr<ParseNode> Parser::ParseCondition() {