e11c6e135348ed8bd4162c0dd7112f7a8f8e4a98
[oota-llvm.git] / tools / llvmc / ConfigLexer.h
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 #include <cassert>
19
20 namespace llvm {
21
22 struct ConfigLexerInfo
23 {
24   int64_t     IntegerVal;
25   std::string StringVal;
26   bool in_value;
27   unsigned lineNum;
28 };
29
30 extern ConfigLexerInfo ConfigLexerState;
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
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)
59   DEFS_SUBST,   ///< The substitution item %defs%
60   EQUALS,       ///< The equals sign, =
61   FALSETOK,     ///< A boolean false value (false/no/off)
62   FOPTS_SUBST,  ///< The substitution item %fOpts%
63   IN_SUBST,     ///< The substitution item %in%
64   INCLS_SUBST,  ///< The substitution item %incls%
65   INTEGER,      ///< An integer 
66   LANG,         ///< The name "lang" (and variants)
67   LIBPATHS,     ///< The name "libpaths" (and variants)
68   LIBS,         ///< The name "libs" (and variants)
69   LIBS_SUBST,   ///< The substitution item %libs%
70   LINKER,       ///< The name "linker" (and variants)
71   MOPTS_SUBST,  ///< The substitution item %Mopts%
72   NAME,         ///< The name "name" (and variants)
73   OPT_SUBST,    ///< The substitution item %opt%
74   OPTIMIZER,    ///< The name "optimizer" (and variants)
75   OPTION,       ///< A command line option
76   OPT1,         ///< The name "opt1" (and variants)
77   OPT2,         ///< The name "opt2" (and variants)
78   OPT3,         ///< The name "opt3" (and variants)
79   OPT4,         ///< The name "opt4" (and variants)
80   OPT5,         ///< The name "opt5" (and variants)
81   OUT_SUBST,    ///< The output substitution item %out%
82   OUTPUT,       ///< The name "output" (and variants)
83   PREPROCESSES, ///< The name "preprocesses" (and variants)
84   PREPROCESSOR, ///< The name "preprocessor" (and variants)
85   REQUIRED,     ///< The name "required" (and variants)
86   SEPARATOR,    ///< A configuration item separator
87   SPACE,        ///< Space between options
88   STATS_SUBST,  ///< The stats substitution item %stats%
89   STRING,       ///< A quoted string
90   TARGET_SUBST, ///< The substitition item %target%
91   TIME_SUBST,   ///< The substitution item %time%
92   TRANSLATES,   ///< The name "translates" (and variants)
93   TRANSLATOR,   ///< The name "translator" (and variants)
94   TRUETOK,      ///< A boolean true value (true/yes/on)
95   VERBOSE_SUBST,///< The substitution item %verbose%
96   VERSION_TOK,  ///< The name "version" (and variants)
97   WOPTS_SUBST,  ///< The %WOpts% substitution
98 };
99
100 extern ConfigLexerTokens Configlex();
101
102 }
103
104 #endif