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