michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef COMPILER_PREPROCESSOR_DIRECTIVE_PARSER_H_ michael@0: #define COMPILER_PREPROCESSOR_DIRECTIVE_PARSER_H_ michael@0: michael@0: #include "Lexer.h" michael@0: #include "Macro.h" michael@0: #include "pp_utils.h" michael@0: #include "SourceLocation.h" michael@0: michael@0: namespace pp michael@0: { michael@0: michael@0: class Diagnostics; michael@0: class DirectiveHandler; michael@0: class Tokenizer; michael@0: michael@0: class DirectiveParser : public Lexer michael@0: { michael@0: public: michael@0: DirectiveParser(Tokenizer* tokenizer, michael@0: MacroSet* macroSet, michael@0: Diagnostics* diagnostics, michael@0: DirectiveHandler* directiveHandler); michael@0: michael@0: virtual void lex(Token* token); michael@0: michael@0: private: michael@0: PP_DISALLOW_COPY_AND_ASSIGN(DirectiveParser); michael@0: michael@0: void parseDirective(Token* token); michael@0: void parseDefine(Token* token); michael@0: void parseUndef(Token* token); michael@0: void parseIf(Token* token); michael@0: void parseIfdef(Token* token); michael@0: void parseIfndef(Token* token); michael@0: void parseElse(Token* token); michael@0: void parseElif(Token* token); michael@0: void parseEndif(Token* token); michael@0: void parseError(Token* token); michael@0: void parsePragma(Token* token); michael@0: void parseExtension(Token* token); michael@0: void parseVersion(Token* token); michael@0: void parseLine(Token* token); michael@0: michael@0: bool skipping() const; michael@0: void parseConditionalIf(Token* token); michael@0: int parseExpressionIf(Token* token); michael@0: int parseExpressionIfdef(Token* token); michael@0: michael@0: struct ConditionalBlock michael@0: { michael@0: std::string type; michael@0: SourceLocation location; michael@0: bool skipBlock; michael@0: bool skipGroup; michael@0: bool foundValidGroup; michael@0: bool foundElseGroup; michael@0: michael@0: ConditionalBlock() : michael@0: skipBlock(false), michael@0: skipGroup(false), michael@0: foundValidGroup(false), michael@0: foundElseGroup(false) michael@0: { michael@0: } michael@0: }; michael@0: bool mPastFirstStatement; michael@0: std::vector mConditionalStack; michael@0: Tokenizer* mTokenizer; michael@0: MacroSet* mMacroSet; michael@0: Diagnostics* mDiagnostics; michael@0: DirectiveHandler* mDirectiveHandler; michael@0: }; michael@0: michael@0: } // namespace pp michael@0: #endif // COMPILER_PREPROCESSOR_DIRECTIVE_PARSER_H_ michael@0: