blob: 8d8205e18febc233b76888bf3d4645d2eaf54ad0 [file] [log] [blame]
Reid Spencer68fb37a2004-08-14 09:37:15 +00001//===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===//
Misha Brukman3da94ae2005-04-22 00:00:37 +00002//
Reid Spencer68fb37a2004-08-14 09:37:15 +00003// The LLVM Compiler Infrastructure
4//
Misha Brukman3da94ae2005-04-22 00:00:37 +00005// This file was developed by Reid Spencer and is distributed under the
Reid Spencer68fb37a2004-08-14 09:37:15 +00006// University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukman3da94ae2005-04-22 00:00:37 +00007//
Reid Spencer68fb37a2004-08-14 09:37:15 +00008//===----------------------------------------------------------------------===//
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 Spencer79030682004-09-01 20:36:15 +000018#include <cassert>
Reid Spencer68fb37a2004-08-14 09:37:15 +000019
20namespace llvm {
21
22struct ConfigLexerInfo
23{
24 int64_t IntegerVal;
25 std::string StringVal;
Reid Spencerbae68252004-08-19 04:49:47 +000026 bool in_value;
27 unsigned lineNum;
Reid Spencer68fb37a2004-08-14 09:37:15 +000028};
29
Reid Spencerbae68252004-08-19 04:49:47 +000030extern ConfigLexerInfo ConfigLexerState;
Reid Spencer68fb37a2004-08-14 09:37:15 +000031
32class 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 Brukman3da94ae2005-04-22 00:00:37 +000040 virtual void error(const std::string& msg);
Reid Spencer68fb37a2004-08-14 09:37:15 +000041 virtual void checkErrors();
42
43 private:
44 std::string name;
45 unsigned errCount;
46};
47
48extern InputProvider* ConfigLexerInput;
49
50enum ConfigLexerTokens {
51 EOFTOK = 0, ///< Returned by Configlex when we hit end of file
52 EOLTOK, ///< End of line
53 ERRORTOK, ///< Error token
Reid Spencerbf394882004-08-24 13:59:35 +000054 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 Spencerca01f9b2004-08-30 06:29:06 +000059 DEFS_SUBST, ///< The substitution item %defs%
Reid Spencer68fb37a2004-08-14 09:37:15 +000060 EQUALS, ///< The equals sign, =
Reid Spencer68fb37a2004-08-14 09:37:15 +000061 FALSETOK, ///< A boolean false value (false/no/off)
Reid Spencerd4ff15a2004-09-14 01:59:31 +000062 FOPTS_SUBST, ///< The substitution item %fOpts%
Reid Spencerbf394882004-08-24 13:59:35 +000063 IN_SUBST, ///< The substitution item %in%
Reid Spencerca01f9b2004-08-30 06:29:06 +000064 INCLS_SUBST, ///< The substitution item %incls%
Misha Brukman3da94ae2005-04-22 00:00:37 +000065 INTEGER, ///< An integer
Reid Spencerbf394882004-08-24 13:59:35 +000066 LANG, ///< The name "lang" (and variants)
67 LIBPATHS, ///< The name "libpaths" (and variants)
68 LIBS, ///< The name "libs" (and variants)
Reid Spencerca01f9b2004-08-30 06:29:06 +000069 LIBS_SUBST, ///< The substitution item %libs%
Reid Spencerbf394882004-08-24 13:59:35 +000070 LINKER, ///< The name "linker" (and variants)
Reid Spencerd4ff15a2004-09-14 01:59:31 +000071 MOPTS_SUBST, ///< The substitution item %Mopts%
Reid Spencerbf394882004-08-24 13:59:35 +000072 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
Reid Spencerc0f376d2004-11-23 23:35:50 +000087 SPACE, ///< Space between options
Reid Spencerbf394882004-08-24 13:59:35 +000088 STATS_SUBST, ///< The stats substitution item %stats%
Reid Spencer68fb37a2004-08-14 09:37:15 +000089 STRING, ///< A quoted string
Reid Spencerbf394882004-08-24 13:59:35 +000090 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)
Reid Spencer52c2dc12004-08-29 19:26:56 +000095 VERBOSE_SUBST,///< The substitution item %verbose%
Reid Spencer0dac2eb2004-10-28 04:06:15 +000096 VERSION_TOK, ///< The name "version" (and variants)
Reid Spencerd4ff15a2004-09-14 01:59:31 +000097 WOPTS_SUBST, ///< The %WOpts% substitution
Reid Spencer68fb37a2004-08-14 09:37:15 +000098};
99
Reid Spencerbf437722004-08-15 08:19:46 +0000100extern ConfigLexerTokens Configlex();
101
Reid Spencer68fb37a2004-08-14 09:37:15 +0000102}
103
104#endif