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> |
Reid Spencer | 7903068 | 2004-09-01 20:36:15 +0000 | [diff] [blame^] | 18 | #include <cassert> |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | struct ConfigLexerInfo |
| 23 | { |
| 24 | int64_t IntegerVal; |
| 25 | std::string StringVal; |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 26 | bool in_value; |
| 27 | unsigned lineNum; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 30 | extern ConfigLexerInfo ConfigLexerState; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 31 | |
| 32 | class InputProvider { |
| 33 | public: |
| 34 | InputProvider(const std::string& nm) { |
| 35 | name = nm; |
| 36 | errCount = 0; |
| 37 | } |
| 38 | virtual ~InputProvider(); |
| 39 | virtual unsigned read(char *buf, unsigned max_size) = 0; |
| 40 | virtual void error(const std::string& msg); |
| 41 | virtual void checkErrors(); |
| 42 | |
| 43 | private: |
| 44 | std::string name; |
| 45 | unsigned errCount; |
| 46 | }; |
| 47 | |
| 48 | extern InputProvider* ConfigLexerInput; |
| 49 | |
| 50 | enum ConfigLexerTokens { |
| 51 | EOFTOK = 0, ///< Returned by Configlex when we hit end of file |
| 52 | EOLTOK, ///< End of line |
| 53 | ERRORTOK, ///< Error token |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 54 | ARGS_SUBST, ///< THe substitution item %args% |
| 55 | ASSEMBLY, ///< The value "assembly" (and variants) |
| 56 | ASSEMBLER, ///< The name "assembler" (and variants) |
| 57 | BYTECODE, ///< The value "bytecode" (and variants) |
| 58 | COMMAND, ///< The name "command" (and variants) |
Reid Spencer | ca01f9b | 2004-08-30 06:29:06 +0000 | [diff] [blame] | 59 | DEFS_SUBST, ///< The substitution item %defs% |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 60 | EQUALS, ///< The equals sign, = |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 61 | FALSETOK, ///< A boolean false value (false/no/off) |
Reid Spencer | 52c2dc1 | 2004-08-29 19:26:56 +0000 | [diff] [blame] | 62 | FORCE_SUBST, ///< The substitution item %force% |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 63 | IN_SUBST, ///< The substitution item %in% |
Reid Spencer | ca01f9b | 2004-08-30 06:29:06 +0000 | [diff] [blame] | 64 | INCLS_SUBST, ///< The substitution item %incls% |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 65 | INTEGER, ///< An integer |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 66 | LANG, ///< The name "lang" (and variants) |
| 67 | LIBPATHS, ///< The name "libpaths" (and variants) |
| 68 | LIBS, ///< The name "libs" (and variants) |
Reid Spencer | ca01f9b | 2004-08-30 06:29:06 +0000 | [diff] [blame] | 69 | LIBS_SUBST, ///< The substitution item %libs% |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 70 | LINKER, ///< The name "linker" (and variants) |
| 71 | NAME, ///< The name "name" (and variants) |
| 72 | OPT_SUBST, ///< The substitution item %opt% |
| 73 | OPTIMIZER, ///< The name "optimizer" (and variants) |
| 74 | OPTION, ///< A command line option |
| 75 | OPT1, ///< The name "opt1" (and variants) |
| 76 | OPT2, ///< The name "opt2" (and variants) |
| 77 | OPT3, ///< The name "opt3" (and variants) |
| 78 | OPT4, ///< The name "opt4" (and variants) |
| 79 | OPT5, ///< The name "opt5" (and variants) |
| 80 | OUT_SUBST, ///< The output substitution item %out% |
| 81 | OUTPUT, ///< The name "output" (and variants) |
| 82 | PREPROCESSES, ///< The name "preprocesses" (and variants) |
| 83 | PREPROCESSOR, ///< The name "preprocessor" (and variants) |
| 84 | REQUIRED, ///< The name "required" (and variants) |
| 85 | SEPARATOR, ///< A configuration item separator |
| 86 | STATS_SUBST, ///< The stats substitution item %stats% |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 87 | STRING, ///< A quoted string |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 88 | TARGET_SUBST, ///< The substitition item %target% |
| 89 | TIME_SUBST, ///< The substitution item %time% |
| 90 | TRANSLATES, ///< The name "translates" (and variants) |
| 91 | TRANSLATOR, ///< The name "translator" (and variants) |
| 92 | TRUETOK, ///< A boolean true value (true/yes/on) |
Reid Spencer | 52c2dc1 | 2004-08-29 19:26:56 +0000 | [diff] [blame] | 93 | VERBOSE_SUBST,///< The substitution item %verbose% |
Reid Spencer | bf39488 | 2004-08-24 13:59:35 +0000 | [diff] [blame] | 94 | VERSION, ///< The name "version" (and variants) |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 97 | extern ConfigLexerTokens Configlex(); |
| 98 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | #endif |