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; |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame^] | 25 | bool in_value; |
| 26 | unsigned lineNum; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 27 | }; |
| 28 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame^] | 29 | extern ConfigLexerInfo ConfigLexerState; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 30 | |
| 31 | class InputProvider { |
| 32 | public: |
| 33 | InputProvider(const std::string& nm) { |
| 34 | name = nm; |
| 35 | errCount = 0; |
| 36 | } |
| 37 | virtual ~InputProvider(); |
| 38 | virtual unsigned read(char *buf, unsigned max_size) = 0; |
| 39 | virtual void error(const std::string& msg); |
| 40 | virtual void checkErrors(); |
| 41 | |
| 42 | private: |
| 43 | std::string name; |
| 44 | unsigned errCount; |
| 45 | }; |
| 46 | |
| 47 | extern InputProvider* ConfigLexerInput; |
| 48 | |
| 49 | enum ConfigLexerTokens { |
| 50 | EOFTOK = 0, ///< Returned by Configlex when we hit end of file |
| 51 | EOLTOK, ///< End of line |
| 52 | ERRORTOK, ///< Error token |
| 53 | OPTION, ///< A command line option |
| 54 | SEPARATOR, ///< A configuration item separator |
| 55 | EQUALS, ///< The equals sign, = |
| 56 | TRUETOK, ///< A boolean true value (true/yes/on) |
| 57 | FALSETOK, ///< A boolean false value (false/no/off) |
| 58 | INTEGER, ///< An integer |
| 59 | STRING, ///< A quoted string |
| 60 | IN_SUBST, ///< The input substitution item @in@ |
| 61 | OUT_SUBST, ///< The output substitution item @out@ |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame^] | 62 | STATS_SUBST, ///< The stats substitution item @stats@ |
| 63 | TIME_SUBST, ///< The substitution item @time@ |
| 64 | OPT_SUBST, ///< The substitution item @opt@ |
| 65 | TARGET_SUBST, ///< The substitition item @target@ |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 66 | LANG, ///< The item "lang" (and case variants) |
| 67 | PREPROCESSOR, ///< The item "preprocessor" (and case variants) |
| 68 | TRANSLATOR, ///< The item "translator" (and case variants) |
| 69 | OPTIMIZER, ///< The item "optimizer" (and case variants) |
| 70 | ASSEMBLER, ///< The item "assembler" (and case variants) |
| 71 | LINKER, ///< The item "linker" (and case variants) |
| 72 | NAME, ///< The item "name" (and case variants) |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 73 | REQUIRED, ///< The item "required" (and case variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 74 | COMMAND, ///< The item "command" (and case variants) |
| 75 | PREPROCESSES, ///< The item "preprocesses" (and case variants) |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame^] | 76 | TRANSLATES, ///< The item "translates" (and case variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 77 | OPTIMIZES, ///< The item "optimizes" (and case variants) |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame^] | 78 | GROKS_DASH_O, ///< The item "groks_dash_O" (and case variants) |
| 79 | OUTPUT_IS_ASM,///< The item "outut_is_asm" (and case variants) |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 80 | OPT1, ///< The item "opt1" (and case variants) |
| 81 | OPT2, ///< The item "opt2" (and case variants) |
| 82 | OPT3, ///< The item "opt3" (and case variants) |
| 83 | OPT4, ///< The item "opt4" (and case variants) |
| 84 | OPT5, ///< The item "opt5" (and case variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 85 | }; |
| 86 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 87 | extern ConfigLexerTokens Configlex(); |
| 88 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | #endif |