Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 1 | //===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===// |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 5 | // This file was developed by Reid Spencer and is distributed under the |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 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; |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 40 | virtual void error(const std::string& msg); |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 41 | virtual void checkErrors(); |
| 42 | |
| 43 | private: |
| 44 | std::string name; |
| 45 | unsigned errCount; |
| 46 | }; |
| 47 | |
| 48 | extern InputProvider* ConfigLexerInput; |
| 49 | |
| 50 | enum ConfigLexerTokens { |
Reid Spencer | cc97cfc | 2005-05-19 00:52:28 +0000 | [diff] [blame] | 51 | EOFTOK = 0, ///< Returned by Configlex when we hit end of file |
| 52 | EOLTOK, ///< End of line |
| 53 | ERRORTOK, ///< Error token |
| 54 | ARGS_SUBST, ///< The substitution item %args% |
| 55 | BINDIR_SUBST, ///< The substitution item %bindir% |
| 56 | ASSEMBLY, ///< The value "assembly" (and variants) |
| 57 | ASSEMBLER, ///< The name "assembler" (and variants) |
| 58 | BYTECODE, ///< The value "bytecode" (and variants) |
| 59 | COMMAND, ///< The name "command" (and variants) |
| 60 | DEFS_SUBST, ///< The substitution item %defs% |
| 61 | EQUALS, ///< The equals sign, = |
| 62 | FALSETOK, ///< A boolean false value (false/no/off) |
| 63 | FOPTS_SUBST, ///< The substitution item %fOpts% |
| 64 | IN_SUBST, ///< The substitution item %in% |
| 65 | INCLS_SUBST, ///< The substitution item %incls% |
| 66 | INTEGER, ///< An integer |
| 67 | LANG, ///< The name "lang" (and variants) |
| 68 | LIBDIR_SUBST, ///< The substitution item %libdir% |
| 69 | LIBPATHS, ///< The name "libpaths" (and variants) |
| 70 | LIBS, ///< The name "libs" (and variants) |
| 71 | LIBS_SUBST, ///< The substitution item %libs% |
| 72 | LINKER, ///< The name "linker" (and variants) |
| 73 | LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir% |
| 74 | LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch% |
| 75 | LLVMGCC_SUBST, ///< The substitution item %llvmgcc% |
| 76 | LLVMGXX_SUBST, ///< The substitution item %llvmgxx% |
| 77 | LLVMCC1_SUBST, ///< The substitution item %llvmcc1% |
| 78 | LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus% |
| 79 | MOPTS_SUBST, ///< The substitution item %Mopts% |
| 80 | NAME, ///< The name "name" (and variants) |
| 81 | OPT_SUBST, ///< The substitution item %opt% |
| 82 | OPTIMIZER, ///< The name "optimizer" (and variants) |
| 83 | OPTION, ///< A command line option |
| 84 | OPT1, ///< The name "opt1" (and variants) |
| 85 | OPT2, ///< The name "opt2" (and variants) |
| 86 | OPT3, ///< The name "opt3" (and variants) |
| 87 | OPT4, ///< The name "opt4" (and variants) |
| 88 | OPT5, ///< The name "opt5" (and variants) |
| 89 | OUT_SUBST, ///< The output substitution item %out% |
| 90 | OUTPUT, ///< The name "output" (and variants) |
| 91 | PREPROCESSES, ///< The name "preprocesses" (and variants) |
| 92 | PREPROCESSOR, ///< The name "preprocessor" (and variants) |
| 93 | REQUIRED, ///< The name "required" (and variants) |
| 94 | SEPARATOR, ///< A configuration item separator |
| 95 | SPACE, ///< Space between options |
| 96 | STATS_SUBST, ///< The stats substitution item %stats% |
| 97 | STRING, ///< A quoted string |
| 98 | TARGET_SUBST, ///< The substitition item %target% |
| 99 | TIME_SUBST, ///< The substitution item %time% |
| 100 | TRANSLATES, ///< The name "translates" (and variants) |
| 101 | TRANSLATOR, ///< The name "translator" (and variants) |
| 102 | TRUETOK, ///< A boolean true value (true/yes/on) |
| 103 | VERBOSE_SUBST, ///< The substitution item %verbose% |
| 104 | VERSION_TOK, ///< The name "version" (and variants) |
Chris Lattner | d74ea2b | 2006-05-24 17:04:05 +0000 | [diff] [blame^] | 105 | WOPTS_SUBST ///< The %WOpts% substitution |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 108 | extern ConfigLexerTokens Configlex(); |
| 109 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | #endif |