blob: 2d5c64e86522f1a52c43e020209bf5f9394d50fc [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 {
Reid Spencercc97cfc2005-05-19 00:52:28 +000051 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 BINDIR_SUBST, ///< The substitution item %bindir%
56 ASSEMBLY, ///< The value "assembly" (and variants)
57 ASSEMBLER, ///< The name "assembler" (and variants)
58 BYTECODE, ///< The value "bytecode" (and variants)
59 COMMAND, ///< The name "command" (and variants)
60 DEFS_SUBST, ///< The substitution item %defs%
61 EQUALS, ///< The equals sign, =
62 FALSETOK, ///< A boolean false value (false/no/off)
63 FOPTS_SUBST, ///< The substitution item %fOpts%
64 IN_SUBST, ///< The substitution item %in%
65 INCLS_SUBST, ///< The substitution item %incls%
66 INTEGER, ///< An integer
67 LANG, ///< The name "lang" (and variants)
68 LIBDIR_SUBST, ///< The substitution item %libdir%
69 LIBPATHS, ///< The name "libpaths" (and variants)
70 LIBS, ///< The name "libs" (and variants)
71 LIBS_SUBST, ///< The substitution item %libs%
72 LINKER, ///< The name "linker" (and variants)
73 LLVMGCCDIR_SUBST, ///< The substitution item %llvmgccdir%
74 LLVMGCCARCH_SUBST, ///< The substitution item %llvmgccarch%
75 LLVMGCC_SUBST, ///< The substitution item %llvmgcc%
76 LLVMGXX_SUBST, ///< The substitution item %llvmgxx%
77 LLVMCC1_SUBST, ///< The substitution item %llvmcc1%
78 LLVMCC1PLUS_SUBST, ///< The substitution item %llvmcc1plus%
79 MOPTS_SUBST, ///< The substitution item %Mopts%
80 NAME, ///< The name "name" (and variants)
81 OPT_SUBST, ///< The substitution item %opt%
82 OPTIMIZER, ///< The name "optimizer" (and variants)
83 OPTION, ///< A command line option
84 OPT1, ///< The name "opt1" (and variants)
85 OPT2, ///< The name "opt2" (and variants)
86 OPT3, ///< The name "opt3" (and variants)
87 OPT4, ///< The name "opt4" (and variants)
88 OPT5, ///< The name "opt5" (and variants)
89 OUT_SUBST, ///< The output substitution item %out%
90 OUTPUT, ///< The name "output" (and variants)
91 PREPROCESSES, ///< The name "preprocesses" (and variants)
92 PREPROCESSOR, ///< The name "preprocessor" (and variants)
93 REQUIRED, ///< The name "required" (and variants)
94 SEPARATOR, ///< A configuration item separator
95 SPACE, ///< Space between options
96 STATS_SUBST, ///< The stats substitution item %stats%
97 STRING, ///< A quoted string
98 TARGET_SUBST, ///< The substitition item %target%
99 TIME_SUBST, ///< The substitution item %time%
100 TRANSLATES, ///< The name "translates" (and variants)
101 TRANSLATOR, ///< The name "translator" (and variants)
102 TRUETOK, ///< A boolean true value (true/yes/on)
103 VERBOSE_SUBST, ///< The substitution item %verbose%
104 VERSION_TOK, ///< The name "version" (and variants)
Chris Lattnerd74ea2b2006-05-24 17:04:05 +0000105 WOPTS_SUBST ///< The %WOpts% substitution
Reid Spencer68fb37a2004-08-14 09:37:15 +0000106};
107
Reid Spencerbf437722004-08-15 08:19:46 +0000108extern ConfigLexerTokens Configlex();
109
Reid Spencer68fb37a2004-08-14 09:37:15 +0000110}
111
112#endif