blob: f947da2bf2c0f0c28a84fcaa22d7e92a74ba8bec [file] [log] [blame]
Reid Spencer68fb37a2004-08-14 09:37:15 +00001//===- 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 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;
40 virtual void error(const std::string& msg);
41 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 Spencer52c2dc12004-08-29 19:26:56 +000062 FORCE_SUBST, ///< The substitution item %force%
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%
Reid Spencer68fb37a2004-08-14 09:37:15 +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)
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 Spencer68fb37a2004-08-14 09:37:15 +000087 STRING, ///< A quoted string
Reid Spencerbf394882004-08-24 13:59:35 +000088 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 Spencer52c2dc12004-08-29 19:26:56 +000093 VERBOSE_SUBST,///< The substitution item %verbose%
Reid Spencerbf394882004-08-24 13:59:35 +000094 VERSION, ///< The name "version" (and variants)
Reid Spencer68fb37a2004-08-14 09:37:15 +000095};
96
Reid Spencerbf437722004-08-15 08:19:46 +000097extern ConfigLexerTokens Configlex();
98
Reid Spencer68fb37a2004-08-14 09:37:15 +000099}
100
101#endif