blob: 78fc30b8b4ac6cb145f5db6e3f58e8233aef8e3f [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>
18
19namespace llvm {
20
21struct ConfigLexerInfo
22{
23 int64_t IntegerVal;
24 std::string StringVal;
Reid Spencerbae68252004-08-19 04:49:47 +000025 bool in_value;
26 unsigned lineNum;
Reid Spencer68fb37a2004-08-14 09:37:15 +000027};
28
Reid Spencerbae68252004-08-19 04:49:47 +000029extern ConfigLexerInfo ConfigLexerState;
Reid Spencer68fb37a2004-08-14 09:37:15 +000030
31class InputProvider {
32 public:
33 InputProvider(const std::string& nm) {
34 name = nm;
35 errCount = 0;
36 }
37 virtual ~InputProvider();
38 virtual unsigned read(char *buf, unsigned max_size) = 0;
39 virtual void error(const std::string& msg);
40 virtual void checkErrors();
41
42 private:
43 std::string name;
44 unsigned errCount;
45};
46
47extern InputProvider* ConfigLexerInput;
48
49enum ConfigLexerTokens {
50 EOFTOK = 0, ///< Returned by Configlex when we hit end of file
51 EOLTOK, ///< End of line
52 ERRORTOK, ///< Error token
53 OPTION, ///< A command line option
54 SEPARATOR, ///< A configuration item separator
55 EQUALS, ///< The equals sign, =
56 TRUETOK, ///< A boolean true value (true/yes/on)
57 FALSETOK, ///< A boolean false value (false/no/off)
58 INTEGER, ///< An integer
59 STRING, ///< A quoted string
60 IN_SUBST, ///< The input substitution item @in@
61 OUT_SUBST, ///< The output substitution item @out@
Reid Spencerbae68252004-08-19 04:49:47 +000062 STATS_SUBST, ///< The stats substitution item @stats@
63 TIME_SUBST, ///< The substitution item @time@
64 OPT_SUBST, ///< The substitution item @opt@
65 TARGET_SUBST, ///< The substitition item @target@
Reid Spencer68fb37a2004-08-14 09:37:15 +000066 LANG, ///< The item "lang" (and case variants)
67 PREPROCESSOR, ///< The item "preprocessor" (and case variants)
68 TRANSLATOR, ///< The item "translator" (and case variants)
69 OPTIMIZER, ///< The item "optimizer" (and case variants)
70 ASSEMBLER, ///< The item "assembler" (and case variants)
71 LINKER, ///< The item "linker" (and case variants)
72 NAME, ///< The item "name" (and case variants)
Reid Spencerbf437722004-08-15 08:19:46 +000073 REQUIRED, ///< The item "required" (and case variants)
Reid Spencer68fb37a2004-08-14 09:37:15 +000074 COMMAND, ///< The item "command" (and case variants)
75 PREPROCESSES, ///< The item "preprocesses" (and case variants)
Reid Spencerbae68252004-08-19 04:49:47 +000076 TRANSLATES, ///< The item "translates" (and case variants)
Reid Spencer68fb37a2004-08-14 09:37:15 +000077 OPTIMIZES, ///< The item "optimizes" (and case variants)
Reid Spencerbae68252004-08-19 04:49:47 +000078 GROKS_DASH_O, ///< The item "groks_dash_O" (and case variants)
79 OUTPUT_IS_ASM,///< The item "outut_is_asm" (and case variants)
Reid Spencerbf437722004-08-15 08:19:46 +000080 OPT1, ///< The item "opt1" (and case variants)
81 OPT2, ///< The item "opt2" (and case variants)
82 OPT3, ///< The item "opt3" (and case variants)
83 OPT4, ///< The item "opt4" (and case variants)
84 OPT5, ///< The item "opt5" (and case variants)
Reid Spencer68fb37a2004-08-14 09:37:15 +000085};
86
Reid Spencerbf437722004-08-15 08:19:46 +000087extern ConfigLexerTokens Configlex();
88
Reid Spencer68fb37a2004-08-14 09:37:15 +000089}
90
91#endif