2004-08-14 09:37:15 +00:00
|
|
|
/*===- ConfigLexer.l - Scanner for CompilerDriver Config Files -*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by Reid Spencer and is distributed under the
|
|
|
|
// University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the flex scanner for configuration files for the
|
|
|
|
// llvmc CompilerDriver.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
|
|
|
|
%option prefix="Config"
|
|
|
|
%option nostdinit
|
|
|
|
%option never-interactive
|
|
|
|
%option batch
|
|
|
|
%option noyywrap
|
|
|
|
%option 8bit
|
|
|
|
%option outfile="ConfigLexer.cpp"
|
|
|
|
%option ecs
|
|
|
|
%option noyymore
|
2004-08-19 04:49:47 +00:00
|
|
|
%option noreject
|
|
|
|
%pointer
|
2004-08-14 09:37:15 +00:00
|
|
|
|
|
|
|
%{
|
|
|
|
|
|
|
|
#include "ConfigLexer.h"
|
|
|
|
|
|
|
|
#define YY_INPUT(buf,result,max_size) \
|
|
|
|
{ \
|
|
|
|
assert(ConfigLexerInput != 0 && "Oops"); \
|
|
|
|
result = ConfigLexerInput->read(buf,max_size); \
|
|
|
|
if (result == 0 ) result = YY_NULL; \
|
|
|
|
}
|
|
|
|
|
2004-08-19 04:49:47 +00:00
|
|
|
#define YY_FATAL_ERROR(msg) \
|
|
|
|
{ \
|
|
|
|
assert(ConfigLexerInput != 0 && "Oops"); \
|
|
|
|
ConfigLexerInput->error(msg); \
|
|
|
|
}
|
|
|
|
|
2004-08-15 08:19:46 +00:00
|
|
|
#define YY_DECL ConfigLexerTokens llvm::Configlex()
|
|
|
|
|
|
|
|
#define yyterminate() { return EOFTOK; }
|
|
|
|
|
2004-08-14 09:37:15 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2004-08-19 04:49:47 +00:00
|
|
|
inline llvm::ConfigLexerTokens
|
2004-08-24 13:58:37 +00:00
|
|
|
handleNameContext(llvm::ConfigLexerTokens token) {
|
|
|
|
ConfigLexerState.StringVal = yytext;
|
|
|
|
if (ConfigLexerState.in_value)
|
2004-08-19 04:49:47 +00:00
|
|
|
return OPTION;
|
|
|
|
return token;
|
2004-08-14 09:37:15 +00:00
|
|
|
}
|
|
|
|
|
2004-08-19 04:49:47 +00:00
|
|
|
inline llvm::ConfigLexerTokens
|
|
|
|
handleSubstitution(llvm::ConfigLexerTokens token) {
|
2004-08-24 13:58:37 +00:00
|
|
|
if (ConfigLexerState.in_value) {
|
|
|
|
ConfigLexerState.StringVal = yytext;
|
2004-08-19 04:49:47 +00:00
|
|
|
return token;
|
2004-08-24 13:58:37 +00:00
|
|
|
}
|
2004-08-19 04:49:47 +00:00
|
|
|
YY_FATAL_ERROR("Substitition tokens not allowed in names" );
|
|
|
|
return ERRORTOK;
|
2006-05-24 17:04:05 +00:00
|
|
|
}
|
2004-08-19 04:49:47 +00:00
|
|
|
|
2004-08-24 13:58:37 +00:00
|
|
|
inline llvm::ConfigLexerTokens handleValueContext(llvm::ConfigLexerTokens token) {
|
|
|
|
ConfigLexerState.StringVal = yytext;
|
2004-08-19 04:49:47 +00:00
|
|
|
if (ConfigLexerState.in_value)
|
|
|
|
return token;
|
2004-08-24 13:58:37 +00:00
|
|
|
return OPTION;
|
2004-08-19 04:49:47 +00:00
|
|
|
}
|
2004-08-14 09:37:15 +00:00
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
ASSEMBLER assembler|Assembler|ASSEMBLER
|
|
|
|
COMMAND command|Command|COMMAND
|
2004-08-19 04:49:47 +00:00
|
|
|
LANG lang|Lang|LANG
|
2004-11-23 23:35:16 +00:00
|
|
|
LIBS libs|Libs|LIBS
|
2007-07-05 17:07:56 +00:00
|
|
|
LINKER linker|Linker|LINKER
|
2004-08-19 04:49:47 +00:00
|
|
|
NAME name|Name|NAME
|
2004-08-15 08:19:46 +00:00
|
|
|
OPT1 opt1|Opt1|OPT1
|
|
|
|
OPT2 opt2|Opt2|OPT2
|
|
|
|
OPT3 opt3|Opt3|OPT3
|
|
|
|
OPT4 opt4|Opt4|OPT4
|
|
|
|
OPT5 opt5|Opt5|OPT5
|
2004-08-19 04:49:47 +00:00
|
|
|
OPTIMIZER optimizer|Optimizer|OPTIMIZER
|
2004-08-24 13:58:37 +00:00
|
|
|
OUTPUT output|Output|OUTPUT
|
2004-08-19 04:49:47 +00:00
|
|
|
PREPROCESSES preprocesses|PreProcesses|PREPROCESSES
|
|
|
|
PREPROCESSOR preprocessor|PreProcessor|PREPROCESSOR
|
|
|
|
REQUIRED required|Required|REQUIRED
|
|
|
|
TRANSLATES translates|Translates|TRANSLATES
|
|
|
|
TRANSLATOR translator|Translator|TRANSLATOR
|
2004-08-22 18:02:13 +00:00
|
|
|
VERSION version|Version|VERSION
|
2004-08-24 13:58:37 +00:00
|
|
|
|
|
|
|
True true|True|TRUE|on|On|ON|yes|Yes|YES
|
|
|
|
False false|False|FALSE|off|Off|OFF|no|No|NO
|
2007-07-05 17:07:56 +00:00
|
|
|
Bitcode bc|BC|bitcode|Bitcode|BITCODE
|
2004-08-24 13:58:37 +00:00
|
|
|
Assembly asm|ASM|assembly|Assembly|ASSEMBLY
|
|
|
|
|
2004-11-23 23:35:16 +00:00
|
|
|
BadSubst \%[a-zA-Z]*\%
|
2004-08-24 13:58:37 +00:00
|
|
|
Comment \#[^\r\n]*\r?\n
|
|
|
|
NewLine \r?\n
|
|
|
|
Eq \=
|
|
|
|
EscNewLine \\\r?\n
|
|
|
|
Option [-A-Za-z0-9_:%+/\\|,][-A-Za-z0-9_:+/\\|,@]*
|
|
|
|
Sep \.
|
|
|
|
String \"[^\"]*\"
|
2004-08-19 04:49:47 +00:00
|
|
|
White [ \t]*
|
|
|
|
|
2004-08-14 09:37:15 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
2004-11-23 23:35:16 +00:00
|
|
|
{White} { if (ConfigLexerState.in_value) return SPACE; }
|
2004-08-14 09:37:15 +00:00
|
|
|
|
2004-08-19 04:49:47 +00:00
|
|
|
{Comment} { /* Ignore comments */
|
|
|
|
ConfigLexerState.in_value = false;
|
|
|
|
ConfigLexerState.lineNum++;
|
|
|
|
return EOLTOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
{EscNewLine} { ConfigLexerState.lineNum++;
|
|
|
|
/* Don't return EOLTOK! */
|
|
|
|
}
|
|
|
|
|
|
|
|
{NewLine} { ConfigLexerState.in_value = false;
|
|
|
|
ConfigLexerState.lineNum++;
|
|
|
|
return EOLTOK;
|
|
|
|
}
|
|
|
|
|
|
|
|
{Eq} { ConfigLexerState.in_value = true;
|
|
|
|
return EQUALS;
|
|
|
|
}
|
|
|
|
|
2004-11-23 23:35:16 +00:00
|
|
|
{Sep} { return SEPARATOR; }
|
|
|
|
|
2004-10-28 04:04:38 +00:00
|
|
|
{VERSION} { return handleNameContext(VERSION_TOK); }
|
2004-08-19 04:49:47 +00:00
|
|
|
|
2004-08-24 13:58:37 +00:00
|
|
|
{LANG} { return handleNameContext(LANG); }
|
2004-11-23 23:35:16 +00:00
|
|
|
{LIBS} { return handleNameContext(LIBS); }
|
2004-08-24 13:58:37 +00:00
|
|
|
{NAME} { return handleNameContext(NAME); }
|
|
|
|
{OPT1} { return handleNameContext(OPT1); }
|
|
|
|
{OPT2} { return handleNameContext(OPT2); }
|
|
|
|
{OPT3} { return handleNameContext(OPT3); }
|
|
|
|
{OPT4} { return handleNameContext(OPT4); }
|
|
|
|
{OPT5} { return handleNameContext(OPT5); }
|
|
|
|
|
|
|
|
{PREPROCESSOR} { return handleNameContext(PREPROCESSOR); }
|
|
|
|
{COMMAND} { return handleNameContext(COMMAND); }
|
|
|
|
{REQUIRED} { return handleNameContext(REQUIRED); }
|
|
|
|
|
|
|
|
{TRANSLATOR} { return handleNameContext(TRANSLATOR); }
|
|
|
|
{PREPROCESSES} { return handleNameContext(PREPROCESSES); }
|
|
|
|
{OUTPUT} { return handleNameContext(OUTPUT); }
|
|
|
|
|
|
|
|
{OPTIMIZER} { return handleNameContext(OPTIMIZER); }
|
|
|
|
{TRANSLATES} { return handleNameContext(TRANSLATES); }
|
|
|
|
|
|
|
|
{ASSEMBLER} { return handleNameContext(ASSEMBLER); }
|
|
|
|
|
|
|
|
{LINKER} { return handleNameContext(LINKER); }
|
|
|
|
|
|
|
|
%args% { return handleSubstitution(ARGS_SUBST); }
|
2005-05-19 00:52:28 +00:00
|
|
|
%bindir% { return handleSubstitution(BINDIR_SUBST); }
|
2004-08-30 06:29:06 +00:00
|
|
|
%defs% { return handleSubstitution(DEFS_SUBST); }
|
2004-08-20 22:53:11 +00:00
|
|
|
%in% { return handleSubstitution(IN_SUBST); }
|
2004-08-30 06:29:06 +00:00
|
|
|
%incls% { return handleSubstitution(INCLS_SUBST); }
|
2005-05-19 00:52:28 +00:00
|
|
|
%libdir% { return handleSubstitution(LIBDIR_SUBST); }
|
2004-08-30 06:29:06 +00:00
|
|
|
%libs% { return handleSubstitution(LIBS_SUBST); }
|
2005-05-19 00:52:28 +00:00
|
|
|
%llvmgccdir% { return handleSubstitution(LLVMGCCDIR_SUBST); }
|
|
|
|
%llvmgccarch% { return handleSubstitution(LLVMGCCARCH_SUBST); }
|
|
|
|
%llvmgcc% { return handleSubstitution(LLVMGCC_SUBST); }
|
|
|
|
%llvmgxx% { return handleSubstitution(LLVMGXX_SUBST); }
|
|
|
|
%llvmcc1% { return handleSubstitution(LLVMCC1_SUBST); }
|
|
|
|
%llvmcc1plus% { return handleSubstitution(LLVMCC1PLUS_SUBST); }
|
2004-08-29 19:26:56 +00:00
|
|
|
%opt% { return handleSubstitution(OPT_SUBST); }
|
2004-08-20 22:53:11 +00:00
|
|
|
%out% { return handleSubstitution(OUT_SUBST); }
|
|
|
|
%stats% { return handleSubstitution(STATS_SUBST); }
|
|
|
|
%target% { return handleSubstitution(TARGET_SUBST); }
|
2004-08-29 19:26:56 +00:00
|
|
|
%time% { return handleSubstitution(TIME_SUBST); }
|
|
|
|
%verbose% { return handleSubstitution(VERBOSE_SUBST); }
|
2004-09-14 01:59:31 +00:00
|
|
|
%fOpts% { return handleSubstitution(FOPTS_SUBST); }
|
|
|
|
%MOpts% { return handleSubstitution(MOPTS_SUBST); }
|
|
|
|
%WOpts% { return handleSubstitution(WOPTS_SUBST); }
|
2004-08-24 13:58:37 +00:00
|
|
|
|
|
|
|
{Assembly} { return handleValueContext(ASSEMBLY); }
|
2007-07-05 17:07:56 +00:00
|
|
|
{Bitcode} { return handleValueContext(BITCODE); }
|
2004-08-24 13:58:37 +00:00
|
|
|
{True} { return handleValueContext(TRUETOK); }
|
|
|
|
{False} { return handleValueContext(FALSETOK); }
|
2004-08-19 04:49:47 +00:00
|
|
|
|
|
|
|
{Option} { ConfigLexerState.StringVal = yytext; return OPTION; }
|
|
|
|
{String} { ConfigLexerState.StringVal = yytext+1; // Nuke start quote
|
|
|
|
ConfigLexerState.StringVal.erase(
|
|
|
|
--ConfigLexerState.StringVal.end());
|
2004-08-14 09:37:15 +00:00
|
|
|
return STRING;
|
|
|
|
}
|
2004-11-23 23:35:16 +00:00
|
|
|
{BadSubst} { YY_FATAL_ERROR("Invalid substitution token"); }
|
2004-08-14 09:37:15 +00:00
|
|
|
|
|
|
|
%%
|