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 | // |
Chris Lattner | 21c62da | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // 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 | // |
Chris Lattner | 74f48d1 | 2006-05-29 18:52:05 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 14 | #ifndef LLVM_TOOLS_LLVMC_CONFIGLEXER_H |
| 15 | #define LLVM_TOOLS_LLVMC_CONFIGLEXER_H |
| 16 | |
| 17 | #include <string> |
| 18 | #include <istream> |
Reid Spencer | 7903068 | 2004-09-01 20:36:15 +0000 | [diff] [blame] | 19 | #include <cassert> |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | struct ConfigLexerInfo |
| 24 | { |
| 25 | int64_t IntegerVal; |
| 26 | std::string StringVal; |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 27 | bool in_value; |
| 28 | unsigned lineNum; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
Reid Spencer | bae6825 | 2004-08-19 04:49:47 +0000 | [diff] [blame] | 31 | extern ConfigLexerInfo ConfigLexerState; |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 32 | |
| 33 | class InputProvider { |
| 34 | public: |
| 35 | InputProvider(const std::string& nm) { |
| 36 | name = nm; |
| 37 | errCount = 0; |
| 38 | } |
| 39 | virtual ~InputProvider(); |
| 40 | virtual unsigned read(char *buf, unsigned max_size) = 0; |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 41 | virtual void error(const std::string& msg); |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 42 | virtual void checkErrors(); |
| 43 | |
| 44 | private: |
| 45 | std::string name; |
| 46 | unsigned errCount; |
| 47 | }; |
| 48 | |
| 49 | extern InputProvider* ConfigLexerInput; |
| 50 | |
| 51 | enum ConfigLexerTokens { |
Reid Spencer | cc97cfc | 2005-05-19 00:52:28 +0000 | [diff] [blame] | 52 | EOFTOK = 0, ///< Returned by Configlex when we hit end of file |
| 53 | EOLTOK, ///< End of line |
| 54 | ERRORTOK, ///< Error token |
| 55 | ARGS_SUBST, ///< The substitution item %args% |
| 56 | BINDIR_SUBST, ///< The substitution item %bindir% |
| 57 | ASSEMBLY, ///< The value "assembly" (and variants) |
| 58 | ASSEMBLER, ///< The name "assembler" (and variants) |
Gabor Greif | a99be51 | 2007-07-05 17:07:56 +0000 | [diff] [blame] | 59 | BITCODE, ///< The value "bitcode" (and variants) |
Reid Spencer | cc97cfc | 2005-05-19 00:52:28 +0000 | [diff] [blame] | 60 | COMMAND, ///< The name "command" (and variants) |
| 61 | DEFS_SUBST, ///< The substitution item %defs% |
| 62 | EQUALS, ///< The equals sign, = |
| 63 | FALSETOK, ///< A boolean false value (false/no/off) |
| 64 | FOPTS_SUBST, ///< The substitution item %fOpts% |
| 65 | IN_SUBST, ///< The substitution item %in% |
| 66 | INCLS_SUBST, ///< The substitution item %incls% |
| 67 | INTEGER, ///< An integer |
| 68 | LANG, ///< The name "lang" (and variants) |
| 69 | LIBDIR_SUBST, ///< The substitution item %libdir% |
| 70 | LIBPATHS, ///< The name "libpaths" (and variants) |
| 71 | LIBS, ///< The name "libs" (and variants) |
| 72 | LIBS_SUBST, ///< The substitution item %libs% |
| 73 | LINKER, ///< The name "linker" (and variants) |
| 74 | LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir% |
| 75 | LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch% |
| 76 | LLVMGCC_SUBST, ///< The substitution item %llvmgcc% |
| 77 | LLVMGXX_SUBST, ///< The substitution item %llvmgxx% |
| 78 | LLVMCC1_SUBST, ///< The substitution item %llvmcc1% |
| 79 | LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus% |
| 80 | MOPTS_SUBST, ///< The substitution item %Mopts% |
| 81 | NAME, ///< The name "name" (and variants) |
| 82 | OPT_SUBST, ///< The substitution item %opt% |
| 83 | OPTIMIZER, ///< The name "optimizer" (and variants) |
| 84 | OPTION, ///< A command line option |
| 85 | OPT1, ///< The name "opt1" (and variants) |
| 86 | OPT2, ///< The name "opt2" (and variants) |
| 87 | OPT3, ///< The name "opt3" (and variants) |
| 88 | OPT4, ///< The name "opt4" (and variants) |
| 89 | OPT5, ///< The name "opt5" (and variants) |
| 90 | OUT_SUBST, ///< The output substitution item %out% |
| 91 | OUTPUT, ///< The name "output" (and variants) |
| 92 | PREPROCESSES, ///< The name "preprocesses" (and variants) |
| 93 | PREPROCESSOR, ///< The name "preprocessor" (and variants) |
| 94 | REQUIRED, ///< The name "required" (and variants) |
| 95 | SEPARATOR, ///< A configuration item separator |
| 96 | SPACE, ///< Space between options |
| 97 | STATS_SUBST, ///< The stats substitution item %stats% |
| 98 | STRING, ///< A quoted string |
| 99 | TARGET_SUBST, ///< The substitition item %target% |
| 100 | TIME_SUBST, ///< The substitution item %time% |
| 101 | TRANSLATES, ///< The name "translates" (and variants) |
| 102 | TRANSLATOR, ///< The name "translator" (and variants) |
| 103 | TRUETOK, ///< A boolean true value (true/yes/on) |
| 104 | VERBOSE_SUBST, ///< The substitution item %verbose% |
| 105 | VERSION_TOK, ///< The name "version" (and variants) |
Chris Lattner | d74ea2b | 2006-05-24 17:04:05 +0000 | [diff] [blame] | 106 | WOPTS_SUBST ///< The %WOpts% substitution |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 107 | }; |
| 108 | |
Reid Spencer | bf43772 | 2004-08-15 08:19:46 +0000 | [diff] [blame] | 109 | extern ConfigLexerTokens Configlex(); |
| 110 | |
Reid Spencer | 68fb37a | 2004-08-14 09:37:15 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | #endif |