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 |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 53 | ARGS_SUBST, ///< THe substitution item %args% |
| 54 | ASSEMBLY, ///< The value "assembly" (and variants) |
| 55 | ASSEMBLER, ///< The name "assembler" (and variants) |
| 56 | BYTECODE, ///< The value "bytecode" (and variants) |
| 57 | COMMAND, ///< The name "command" (and variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 58 | EQUALS, ///< The equals sign, = |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 59 | FALSETOK, ///< A boolean false value (false/no/off) |
Reid Spencer | 52c2dc1 | 2004-08-29 19:26:56 +0000 | [diff] [blame^] | 60 | FORCE_SUBST, ///< The substitution item %force% |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 61 | IN_SUBST, ///< The substitution item %in% |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 62 | INTEGER, ///< An integer |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 63 | LANG, ///< The name "lang" (and variants) |
| 64 | LIBPATHS, ///< The name "libpaths" (and variants) |
| 65 | LIBS, ///< The name "libs" (and variants) |
| 66 | LINKER, ///< The name "linker" (and variants) |
| 67 | NAME, ///< The name "name" (and variants) |
| 68 | OPT_SUBST, ///< The substitution item %opt% |
| 69 | OPTIMIZER, ///< The name "optimizer" (and variants) |
| 70 | OPTION, ///< A command line option |
| 71 | OPT1, ///< The name "opt1" (and variants) |
| 72 | OPT2, ///< The name "opt2" (and variants) |
| 73 | OPT3, ///< The name "opt3" (and variants) |
| 74 | OPT4, ///< The name "opt4" (and variants) |
| 75 | OPT5, ///< The name "opt5" (and variants) |
| 76 | OUT_SUBST, ///< The output substitution item %out% |
| 77 | OUTPUT, ///< The name "output" (and variants) |
| 78 | PREPROCESSES, ///< The name "preprocesses" (and variants) |
| 79 | PREPROCESSOR, ///< The name "preprocessor" (and variants) |
| 80 | REQUIRED, ///< The name "required" (and variants) |
| 81 | SEPARATOR, ///< A configuration item separator |
| 82 | STATS_SUBST, ///< The stats substitution item %stats% |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 83 | STRING, ///< A quoted string |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 84 | TARGET_SUBST, ///< The substitition item %target% |
| 85 | TIME_SUBST, ///< The substitution item %time% |
| 86 | TRANSLATES, ///< The name "translates" (and variants) |
| 87 | TRANSLATOR, ///< The name "translator" (and variants) |
| 88 | TRUETOK, ///< A boolean true value (true/yes/on) |
Reid Spencer | 52c2dc1 | 2004-08-29 19:26:56 +0000 | [diff] [blame^] | 89 | VERBOSE_SUBST,///< The substitution item %verbose% |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 90 | VERSION, ///< The name "version" (and variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 93 | extern ConfigLexerTokens Configlex(); |
| 94 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | #endif |