• Home
  • Raw
  • Download

Lines Matching refs:token

45 DirectiveType getDirective(const pp::Token *token)  in getDirective()  argument
61 if (token->type != pp::Token::IDENTIFIER) in getDirective()
64 if (token->text == kDirectiveDefine) in getDirective()
66 if (token->text == kDirectiveUndef) in getDirective()
68 if (token->text == kDirectiveIf) in getDirective()
70 if (token->text == kDirectiveIfdef) in getDirective()
72 if (token->text == kDirectiveIfndef) in getDirective()
74 if (token->text == kDirectiveElse) in getDirective()
76 if (token->text == kDirectiveElif) in getDirective()
78 if (token->text == kDirectiveEndif) in getDirective()
80 if (token->text == kDirectiveError) in getDirective()
82 if (token->text == kDirectivePragma) in getDirective()
84 if (token->text == kDirectiveExtension) in getDirective()
86 if (token->text == kDirectiveVersion) in getDirective()
88 if (token->text == kDirectiveLine) in getDirective()
111 bool isEOD(const pp::Token *token) in isEOD() argument
113 return (token->type == '\n') || (token->type == pp::Token::LAST); in isEOD()
116 void skipUntilEOD(pp::Lexer *lexer, pp::Token *token) in skipUntilEOD() argument
118 while (!isEOD(token)) in skipUntilEOD()
120 lexer->lex(token); in skipUntilEOD()
162 void DirectiveParser::lex(Token *token) in lex() argument
166 mTokenizer->lex(token); in lex()
168 if (token->type == Token::PP_HASH) in lex()
170 parseDirective(token); in lex()
173 else if (!isEOD(token) && !skipping()) in lex()
178 if (token->type == Token::LAST) in lex()
189 } while (skipping() || (token->type == '\n')); in lex()
194 void DirectiveParser::parseDirective(Token *token) in parseDirective() argument
196 ASSERT(token->type == Token::PP_HASH); in parseDirective()
198 mTokenizer->lex(token); in parseDirective()
199 if (isEOD(token)) in parseDirective()
205 DirectiveType directive = getDirective(token); in parseDirective()
211 skipUntilEOD(mTokenizer, token); in parseDirective()
218 mDiagnostics->report(Diagnostics::PP_DIRECTIVE_INVALID_NAME, token->location, in parseDirective()
219 token->text); in parseDirective()
220 skipUntilEOD(mTokenizer, token); in parseDirective()
223 parseDefine(token); in parseDirective()
226 parseUndef(token); in parseDirective()
229 parseIf(token); in parseDirective()
232 parseIfdef(token); in parseDirective()
235 parseIfndef(token); in parseDirective()
238 parseElse(token); in parseDirective()
241 parseElif(token); in parseDirective()
244 parseEndif(token); in parseDirective()
247 parseError(token); in parseDirective()
250 parsePragma(token); in parseDirective()
253 parseExtension(token); in parseDirective()
256 parseVersion(token); in parseDirective()
259 parseLine(token); in parseDirective()
266 skipUntilEOD(mTokenizer, token); in parseDirective()
267 if (token->type == Token::LAST) in parseDirective()
269 mDiagnostics->report(Diagnostics::PP_EOF_IN_DIRECTIVE, token->location, token->text); in parseDirective()
273 void DirectiveParser::parseDefine(Token *token) in parseDefine() argument
275 ASSERT(getDirective(token) == DIRECTIVE_DEFINE); in parseDefine()
277 mTokenizer->lex(token); in parseDefine()
278 if (token->type != Token::IDENTIFIER) in parseDefine()
280 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); in parseDefine()
283 if (isMacroPredefined(token->text, *mMacroSet)) in parseDefine()
285 mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_REDEFINED, token->location, in parseDefine()
286 token->text); in parseDefine()
289 if (isMacroNameReserved(token->text)) in parseDefine()
291 mDiagnostics->report(Diagnostics::PP_MACRO_NAME_RESERVED, token->location, token->text); in parseDefine()
299 if (hasDoubleUnderscores(token->text)) in parseDefine()
301 mDiagnostics->report(Diagnostics::PP_WARNING_MACRO_NAME_RESERVED, token->location, in parseDefine()
302 token->text); in parseDefine()
307 macro->name = token->text; in parseDefine()
309 mTokenizer->lex(token); in parseDefine()
310 if (token->type == '(' && !token->hasLeadingSpace()) in parseDefine()
316 mTokenizer->lex(token); in parseDefine()
317 if (token->type != Token::IDENTIFIER) in parseDefine()
320 if (std::find(macro->parameters.begin(), macro->parameters.end(), token->text) != in parseDefine()
324 token->location, token->text); in parseDefine()
328 macro->parameters.push_back(token->text); in parseDefine()
330 mTokenizer->lex(token); // Get ','. in parseDefine()
331 } while (token->type == ','); in parseDefine()
333 if (token->type != ')') in parseDefine()
335 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); in parseDefine()
338 mTokenizer->lex(token); // Get ')'. in parseDefine()
341 while ((token->type != '\n') && (token->type != Token::LAST)) in parseDefine()
346 token->location = SourceLocation(); in parseDefine()
347 macro->replacements.push_back(*token); in parseDefine()
348 mTokenizer->lex(token); in parseDefine()
361 mDiagnostics->report(Diagnostics::PP_MACRO_REDEFINED, token->location, macro->name); in parseDefine()
367 void DirectiveParser::parseUndef(Token *token) in parseUndef() argument
369 ASSERT(getDirective(token) == DIRECTIVE_UNDEF); in parseUndef()
371 mTokenizer->lex(token); in parseUndef()
372 if (token->type != Token::IDENTIFIER) in parseUndef()
374 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); in parseUndef()
378 MacroSet::iterator iter = mMacroSet->find(token->text); in parseUndef()
383 mDiagnostics->report(Diagnostics::PP_MACRO_PREDEFINED_UNDEFINED, token->location, in parseUndef()
384 token->text); in parseUndef()
389 mDiagnostics->report(Diagnostics::PP_MACRO_UNDEFINED_WHILE_INVOKED, token->location, in parseUndef()
390 token->text); in parseUndef()
399 mTokenizer->lex(token); in parseUndef()
400 if (!isEOD(token)) in parseUndef()
402 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); in parseUndef()
403 skipUntilEOD(mTokenizer, token); in parseUndef()
407 void DirectiveParser::parseIf(Token *token) in parseIf() argument
409 ASSERT(getDirective(token) == DIRECTIVE_IF); in parseIf()
410 parseConditionalIf(token); in parseIf()
413 void DirectiveParser::parseIfdef(Token *token) in parseIfdef() argument
415 ASSERT(getDirective(token) == DIRECTIVE_IFDEF); in parseIfdef()
416 parseConditionalIf(token); in parseIfdef()
419 void DirectiveParser::parseIfndef(Token *token) in parseIfndef() argument
421 ASSERT(getDirective(token) == DIRECTIVE_IFNDEF); in parseIfndef()
422 parseConditionalIf(token); in parseIfndef()
425 void DirectiveParser::parseElse(Token *token) in parseElse() argument
427 ASSERT(getDirective(token) == DIRECTIVE_ELSE); in parseElse()
431 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_WITHOUT_IF, token->location, in parseElse()
432 token->text); in parseElse()
433 skipUntilEOD(mTokenizer, token); in parseElse()
441 skipUntilEOD(mTokenizer, token); in parseElse()
446 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELSE_AFTER_ELSE, token->location, in parseElse()
447 token->text); in parseElse()
448 skipUntilEOD(mTokenizer, token); in parseElse()
457 mTokenizer->lex(token); in parseElse()
458 if (!isEOD(token)) in parseElse()
460 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, in parseElse()
461 token->text); in parseElse()
462 skipUntilEOD(mTokenizer, token); in parseElse()
466 void DirectiveParser::parseElif(Token *token) in parseElif() argument
468 ASSERT(getDirective(token) == DIRECTIVE_ELIF); in parseElif()
472 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_WITHOUT_IF, token->location, in parseElif()
473 token->text); in parseElif()
474 skipUntilEOD(mTokenizer, token); in parseElif()
482 skipUntilEOD(mTokenizer, token); in parseElif()
487 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ELIF_AFTER_ELSE, token->location, in parseElif()
488 token->text); in parseElif()
489 skipUntilEOD(mTokenizer, token); in parseElif()
497 skipUntilEOD(mTokenizer, token); in parseElif()
501 int expression = parseExpressionIf(token); in parseElif()
506 void DirectiveParser::parseEndif(Token *token) in parseEndif() argument
508 ASSERT(getDirective(token) == DIRECTIVE_ENDIF); in parseEndif()
512 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_ENDIF_WITHOUT_IF, token->location, in parseEndif()
513 token->text); in parseEndif()
514 skipUntilEOD(mTokenizer, token); in parseEndif()
521 mTokenizer->lex(token); in parseEndif()
522 if (!isEOD(token)) in parseEndif()
524 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, in parseEndif()
525 token->text); in parseEndif()
526 skipUntilEOD(mTokenizer, token); in parseEndif()
530 void DirectiveParser::parseError(Token *token) in parseError() argument
532 ASSERT(getDirective(token) == DIRECTIVE_ERROR); in parseError()
535 mTokenizer->lex(token); in parseError()
536 while ((token->type != '\n') && (token->type != Token::LAST)) in parseError()
538 stream << *token; in parseError()
539 mTokenizer->lex(token); in parseError()
541 mDirectiveHandler->handleError(token->location, stream.str()); in parseError()
545 void DirectiveParser::parsePragma(Token *token) in parsePragma() argument
547 ASSERT(getDirective(token) == DIRECTIVE_PRAGMA); in parsePragma()
561 mTokenizer->lex(token); in parsePragma()
562 bool stdgl = token->text == "STDGL"; in parsePragma()
565 mTokenizer->lex(token); in parsePragma()
567 while ((token->type != '\n') && (token->type != Token::LAST)) in parsePragma()
572 name = token->text; in parsePragma()
573 valid = valid && (token->type == Token::IDENTIFIER); in parsePragma()
576 valid = valid && (token->type == '('); in parsePragma()
579 value = token->text; in parsePragma()
580 valid = valid && (token->type == Token::IDENTIFIER); in parsePragma()
583 valid = valid && (token->type == ')'); in parsePragma()
589 mTokenizer->lex(token); in parsePragma()
597 mDiagnostics->report(Diagnostics::PP_UNRECOGNIZED_PRAGMA, token->location, name); in parsePragma()
601 mDirectiveHandler->handlePragma(token->location, name, value, stdgl); in parsePragma()
605 void DirectiveParser::parseExtension(Token *token) in parseExtension() argument
607 ASSERT(getDirective(token) == DIRECTIVE_EXTENSION); in parseExtension()
620 mTokenizer->lex(token); in parseExtension()
621 while ((token->type != '\n') && (token->type != Token::LAST)) in parseExtension()
626 if (valid && (token->type != Token::IDENTIFIER)) in parseExtension()
628 mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_NAME, token->location, in parseExtension()
629 token->text); in parseExtension()
633 name = token->text; in parseExtension()
636 if (valid && (token->type != ':')) in parseExtension()
638 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, in parseExtension()
639 token->text); in parseExtension()
644 if (valid && (token->type != Token::IDENTIFIER)) in parseExtension()
647 token->location, token->text); in parseExtension()
651 behavior = token->text; in parseExtension()
656 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, in parseExtension()
657 token->text); in parseExtension()
662 mTokenizer->lex(token); in parseExtension()
666 mDiagnostics->report(Diagnostics::PP_INVALID_EXTENSION_DIRECTIVE, token->location, in parseExtension()
667 token->text); in parseExtension()
675 token->location, token->text); in parseExtension()
683 token->location, token->text); in parseExtension()
688 token->location, token->text); in parseExtension()
697 mDirectiveHandler->handleExtension(token->location, name, behavior); in parseExtension()
700 void DirectiveParser::parseVersion(Token *token) in parseVersion() argument
702 ASSERT(getDirective(token) == DIRECTIVE_VERSION); in parseVersion()
706 mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_STATEMENT, token->location, in parseVersion()
707 token->text); in parseVersion()
708 skipUntilEOD(mTokenizer, token); in parseVersion()
724 mTokenizer->lex(token); in parseVersion()
725 while (valid && (token->type != '\n') && (token->type != Token::LAST)) in parseVersion()
730 if (token->type != Token::CONST_INT) in parseVersion()
732 mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_NUMBER, token->location, in parseVersion()
733 token->text); in parseVersion()
736 if (valid && !token->iValue(&version)) in parseVersion()
738 mDiagnostics->report(Diagnostics::PP_INTEGER_OVERFLOW, token->location, in parseVersion()
739 token->text); in parseVersion()
760 if (token->type != Token::IDENTIFIER || token->text != "es") in parseVersion()
762 mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, in parseVersion()
763 token->text); in parseVersion()
770 if (token->type != Token::IDENTIFIER || token->text != "core") in parseVersion()
772 mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, in parseVersion()
773 token->text); in parseVersion()
779 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, in parseVersion()
780 token->text); in parseVersion()
785 mTokenizer->lex(token); in parseVersion()
787 if (token->type == '\n' && state == VERSION_PROFILE_GL) in parseVersion()
795 mDiagnostics->report(Diagnostics::PP_INVALID_VERSION_DIRECTIVE, token->location, in parseVersion()
796 token->text); in parseVersion()
800 if (valid && version >= 300 && token->location.line > 1) in parseVersion()
802 mDiagnostics->report(Diagnostics::PP_VERSION_NOT_FIRST_LINE_ESSL3, token->location, in parseVersion()
803 token->text); in parseVersion()
809 mDirectiveHandler->handleVersion(token->location, version, mSettings.shaderSpec); in parseVersion()
815 void DirectiveParser::parseLine(Token *token) in parseLine() argument
817 ASSERT(getDirective(token) == DIRECTIVE_LINE); in parseLine()
826 macroExpander.lex(token); in parseLine()
828 if (isEOD(token)) in parseLine()
830 mDiagnostics->report(Diagnostics::PP_INVALID_LINE_DIRECTIVE, token->location, token->text); in parseLine()
845 expressionParser.parse(token, &line, true, errorSettings, &valid); in parseLine()
846 if (!isEOD(token) && valid) in parseLine()
854 expressionParser.parse(token, &file, true, errorSettings, &valid); in parseLine()
857 if (!isEOD(token)) in parseLine()
861 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, in parseLine()
862 token->text); in parseLine()
865 skipUntilEOD(mTokenizer, token); in parseLine()
886 void DirectiveParser::parseConditionalIf(Token *token) in parseConditionalIf() argument
889 block.type = token->text; in parseConditionalIf()
890 block.location = token->location; in parseConditionalIf()
898 skipUntilEOD(mTokenizer, token); in parseConditionalIf()
903 DirectiveType directive = getDirective(token); in parseConditionalIf()
909 expression = parseExpressionIf(token); in parseConditionalIf()
912 expression = parseExpressionIfdef(token); in parseConditionalIf()
915 expression = parseExpressionIfdef(token) == 0 ? 1 : 0; in parseConditionalIf()
927 int DirectiveParser::parseExpressionIf(Token *token) in parseExpressionIf() argument
929 ASSERT((getDirective(token) == DIRECTIVE_IF) || (getDirective(token) == DIRECTIVE_ELIF)); in parseExpressionIf()
940 expressionParser.parse(token, &expression, false, errorSettings, &valid); in parseExpressionIf()
943 if (!isEOD(token)) in parseExpressionIf()
945 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, in parseExpressionIf()
946 token->text); in parseExpressionIf()
947 skipUntilEOD(mTokenizer, token); in parseExpressionIf()
953 int DirectiveParser::parseExpressionIfdef(Token *token) in parseExpressionIfdef() argument
955 ASSERT((getDirective(token) == DIRECTIVE_IFDEF) || (getDirective(token) == DIRECTIVE_IFNDEF)); in parseExpressionIfdef()
957 mTokenizer->lex(token); in parseExpressionIfdef()
958 if (token->type != Token::IDENTIFIER) in parseExpressionIfdef()
960 mDiagnostics->report(Diagnostics::PP_UNEXPECTED_TOKEN, token->location, token->text); in parseExpressionIfdef()
961 skipUntilEOD(mTokenizer, token); in parseExpressionIfdef()
965 MacroSet::const_iterator iter = mMacroSet->find(token->text); in parseExpressionIfdef()
969 mTokenizer->lex(token); in parseExpressionIfdef()
970 if (!isEOD(token)) in parseExpressionIfdef()
972 mDiagnostics->report(Diagnostics::PP_CONDITIONAL_UNEXPECTED_TOKEN, token->location, in parseExpressionIfdef()
973 token->text); in parseExpressionIfdef()
974 skipUntilEOD(mTokenizer, token); in parseExpressionIfdef()