blob: 3b413c28deb3e884f5d53ca6865f47e4526e96e9 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- ConfigLexer.h - ConfigLexer Declarations -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner5f5a5732007-12-29 20:44:31 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the types and data needed by ConfigLexer.l
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TOOLS_LLVMC_CONFIGLEXER_H
15#define LLVM_TOOLS_LLVMC_CONFIGLEXER_H
16
17#include <string>
18#include <istream>
19#include <cassert>
20
21namespace llvm {
22
23struct ConfigLexerInfo
24{
25 int64_t IntegerVal;
26 std::string StringVal;
27 bool in_value;
28 unsigned lineNum;
29};
30
31extern ConfigLexerInfo ConfigLexerState;
32
33class 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;
41 virtual void error(const std::string& msg);
42 virtual void checkErrors();
43
44 private:
45 std::string name;
46 unsigned errCount;
47};
48
49extern InputProvider* ConfigLexerInput;
50
51enum ConfigLexerTokens {
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)
59 BITCODE, ///< The value "bitcode" (and variants)
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)
106 WOPTS_SUBST ///< The %WOpts% substitution
107};
108
109extern ConfigLexerTokens Configlex();
110
111}
112
113#endif