Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 1 | //===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Reid Spencer and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file declares the types and data needed by ConfigLexer.l |
| 11 | // |
| 12 | //===------------------------------------------------------------------------=== |
| 13 | #ifndef LLVM_TOOLS_LLVMC_CONFIGLEXER_H |
| 14 | #define LLVM_TOOLS_LLVMC_CONFIGLEXER_H |
| 15 | |
| 16 | #include <string> |
| 17 | #include <istream> |
| 18 | |
| 19 | namespace llvm { |
| 20 | |
| 21 | struct ConfigLexerInfo |
| 22 | { |
| 23 | int64_t IntegerVal; |
| 24 | std::string StringVal; |
| 25 | }; |
| 26 | |
| 27 | extern ConfigLexerInfo ConfigLexerData; |
| 28 | extern unsigned ConfigLexerLine; |
| 29 | |
| 30 | class InputProvider { |
| 31 | public: |
| 32 | InputProvider(const std::string& nm) { |
| 33 | name = nm; |
| 34 | errCount = 0; |
| 35 | } |
| 36 | virtual ~InputProvider(); |
| 37 | virtual unsigned read(char *buf, unsigned max_size) = 0; |
| 38 | virtual void error(const std::string& msg); |
| 39 | virtual void checkErrors(); |
| 40 | |
| 41 | private: |
| 42 | std::string name; |
| 43 | unsigned errCount; |
| 44 | }; |
| 45 | |
| 46 | extern InputProvider* ConfigLexerInput; |
| 47 | |
| 48 | enum ConfigLexerTokens { |
| 49 | EOFTOK = 0, ///< Returned by Configlex when we hit end of file |
| 50 | EOLTOK, ///< End of line |
| 51 | ERRORTOK, ///< Error token |
| 52 | OPTION, ///< A command line option |
| 53 | SEPARATOR, ///< A configuration item separator |
| 54 | EQUALS, ///< The equals sign, = |
| 55 | TRUETOK, ///< A boolean true value (true/yes/on) |
| 56 | FALSETOK, ///< A boolean false value (false/no/off) |
| 57 | INTEGER, ///< An integer |
| 58 | STRING, ///< A quoted string |
| 59 | IN_SUBST, ///< The input substitution item @in@ |
| 60 | OUT_SUBST, ///< The output substitution item @out@ |
| 61 | LANG, ///< The item "lang" (and case variants) |
| 62 | PREPROCESSOR, ///< The item "preprocessor" (and case variants) |
| 63 | TRANSLATOR, ///< The item "translator" (and case variants) |
| 64 | OPTIMIZER, ///< The item "optimizer" (and case variants) |
| 65 | ASSEMBLER, ///< The item "assembler" (and case variants) |
| 66 | LINKER, ///< The item "linker" (and case variants) |
| 67 | NAME, ///< The item "name" (and case variants) |
| 68 | NEEDED, ///< The item "needed" (and case variants) |
| 69 | COMMAND, ///< The item "command" (and case variants) |
| 70 | PREPROCESSES, ///< The item "preprocesses" (and case variants) |
| 71 | GROKS_DASH_O, ///< The item "groks_dash_O" (and case variants) |
| 72 | OPTIMIZES, ///< The item "optimizes" (and case variants) |
| 73 | }; |
| 74 | |
| 75 | } |
| 76 | |
| 77 | #endif |