blob: 3b413c28deb3e884f5d53ca6865f47e4526e96e9 [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//
Chris Lattner21c62da2007-12-29 20:44:31 +00005// This file is distributed under the University of Illinois Open Source
6// 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//
Chris Lattner74f48d12006-05-29 18:52:05 +000012//===----------------------------------------------------------------------===//
13
Reid Spencer68fb37a2004-08-14 09:37:15 +000014#ifndef LLVM_TOOLS_LLVMC_CONFIGLEXER_H
15#define LLVM_TOOLS_LLVMC_CONFIGLEXER_H
16
17#include <string>
18#include <istream>
Reid Spencer79030682004-09-01 20:36:15 +000019#include <cassert>
Reid Spencer68fb37a2004-08-14 09:37:15 +000020
21namespace llvm {
22
23struct ConfigLexerInfo
24{
25 int64_t IntegerVal;
26 std::string StringVal;
Reid Spencerbae68252004-08-19 04:49:47 +000027 bool in_value;
28 unsigned lineNum;
Reid Spencer68fb37a2004-08-14 09:37:15 +000029};
30
Reid Spencerbae68252004-08-19 04:49:47 +000031extern ConfigLexerInfo ConfigLexerState;
Reid Spencer68fb37a2004-08-14 09:37:15 +000032
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;
Misha Brukman3da94ae2005-04-22 00:00:37 +000041 virtual void error(const std::string& msg);
Reid Spencer68fb37a2004-08-14 09:37:15 +000042 virtual void checkErrors();
43
44 private:
45 std::string name;
46 unsigned errCount;
47};
48
49extern InputProvider* ConfigLexerInput;
50
51enum ConfigLexerTokens {
Reid Spencercc97cfc2005-05-19 00:52:28 +000052 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 Greifa99be512007-07-05 17:07:56 +000059 BITCODE, ///< The value "bitcode" (and variants)
Reid Spencercc97cfc2005-05-19 00:52:28 +000060 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 Lattnerd74ea2b2006-05-24 17:04:05 +0000106 WOPTS_SUBST ///< The %WOpts% substitution
Reid Spencer68fb37a2004-08-14 09:37:15 +0000107};
108
Reid Spencerbf437722004-08-15 08:19:46 +0000109extern ConfigLexerTokens Configlex();
110
Reid Spencer68fb37a2004-08-14 09:37:15 +0000111}
112
113#endif