diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-14 05:16:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-14 05:16:35 +0000 |
commit | 1828ee191c6686309921f5b37a3e74ce8ecb795c (patch) | |
tree | 812e643c7beb979f22dbd3ed80372bab5e70589c /tools/llvmc | |
parent | 32eecb09a20bad30b23c38a910d2431eabfb5f8d (diff) | |
download | external_llvm-1828ee191c6686309921f5b37a3e74ce8ecb795c.zip external_llvm-1828ee191c6686309921f5b37a3e74ce8ecb795c.tar.gz external_llvm-1828ee191c6686309921f5b37a3e74ce8ecb795c.tar.bz2 |
Adjust to new style "generated files in CVS" mechanism for lex output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26163 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvmc')
-rw-r--r-- | tools/llvmc/ConfigLexer.cpp.cvs (renamed from tools/llvmc/ConfigLexer.cpp) | 0 | ||||
-rw-r--r-- | tools/llvmc/ConfigLexer.l.cvs | 201 |
2 files changed, 201 insertions, 0 deletions
diff --git a/tools/llvmc/ConfigLexer.cpp b/tools/llvmc/ConfigLexer.cpp.cvs index 3a8652e..3a8652e 100644 --- a/tools/llvmc/ConfigLexer.cpp +++ b/tools/llvmc/ConfigLexer.cpp.cvs diff --git a/tools/llvmc/ConfigLexer.l.cvs b/tools/llvmc/ConfigLexer.l.cvs new file mode 100644 index 0000000..ca21f4f --- /dev/null +++ b/tools/llvmc/ConfigLexer.l.cvs @@ -0,0 +1,201 @@ +/*===- 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 +%option noreject +%pointer + +%{ + +#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; \ + } + +#define YY_FATAL_ERROR(msg) \ + { \ + assert(ConfigLexerInput != 0 && "Oops"); \ + ConfigLexerInput->error(msg); \ + } + +#define YY_DECL ConfigLexerTokens llvm::Configlex() + +#define yyterminate() { return EOFTOK; } + +using namespace llvm; + +inline llvm::ConfigLexerTokens +handleNameContext(llvm::ConfigLexerTokens token) { + ConfigLexerState.StringVal = yytext; + if (ConfigLexerState.in_value) + return OPTION; + return token; +} + +inline llvm::ConfigLexerTokens +handleSubstitution(llvm::ConfigLexerTokens token) { + if (ConfigLexerState.in_value) { + ConfigLexerState.StringVal = yytext; + return token; + } + YY_FATAL_ERROR("Substitition tokens not allowed in names" ); + return ERRORTOK; +}; + +inline llvm::ConfigLexerTokens handleValueContext(llvm::ConfigLexerTokens token) { + ConfigLexerState.StringVal = yytext; + if (ConfigLexerState.in_value) + return token; + return OPTION; +} + +%} + +ASSEMBLER assembler|Assembler|ASSEMBLER +COMMAND command|Command|COMMAND +LANG lang|Lang|LANG +LIBS libs|Libs|LIBS +LINKER linker|Linker|LINKER +NAME name|Name|NAME +OPT1 opt1|Opt1|OPT1 +OPT2 opt2|Opt2|OPT2 +OPT3 opt3|Opt3|OPT3 +OPT4 opt4|Opt4|OPT4 +OPT5 opt5|Opt5|OPT5 +OPTIMIZER optimizer|Optimizer|OPTIMIZER +OUTPUT output|Output|OUTPUT +PREPROCESSES preprocesses|PreProcesses|PREPROCESSES +PREPROCESSOR preprocessor|PreProcessor|PREPROCESSOR +REQUIRED required|Required|REQUIRED +TRANSLATES translates|Translates|TRANSLATES +TRANSLATOR translator|Translator|TRANSLATOR +VERSION version|Version|VERSION + +True true|True|TRUE|on|On|ON|yes|Yes|YES +False false|False|FALSE|off|Off|OFF|no|No|NO +Bytecode bc|BC|bytecode|Bytecode|BYTECODE +Assembly asm|ASM|assembly|Assembly|ASSEMBLY + +BadSubst \%[a-zA-Z]*\% +Comment \#[^\r\n]*\r?\n +NewLine \r?\n +Eq \= +EscNewLine \\\r?\n +Option [-A-Za-z0-9_:%+/\\|,][-A-Za-z0-9_:+/\\|,@]* +Sep \. +String \"[^\"]*\" +White [ \t]* + + +%% + +{White} { if (ConfigLexerState.in_value) return SPACE; } + +{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; + } + +{Sep} { return SEPARATOR; } + +{VERSION} { return handleNameContext(VERSION_TOK); } + +{LANG} { return handleNameContext(LANG); } +{LIBS} { return handleNameContext(LIBS); } +{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); } +%bindir% { return handleSubstitution(BINDIR_SUBST); } +%defs% { return handleSubstitution(DEFS_SUBST); } +%in% { return handleSubstitution(IN_SUBST); } +%incls% { return handleSubstitution(INCLS_SUBST); } +%libdir% { return handleSubstitution(LIBDIR_SUBST); } +%libs% { return handleSubstitution(LIBS_SUBST); } +%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); } +%opt% { return handleSubstitution(OPT_SUBST); } +%out% { return handleSubstitution(OUT_SUBST); } +%stats% { return handleSubstitution(STATS_SUBST); } +%target% { return handleSubstitution(TARGET_SUBST); } +%time% { return handleSubstitution(TIME_SUBST); } +%verbose% { return handleSubstitution(VERBOSE_SUBST); } +%fOpts% { return handleSubstitution(FOPTS_SUBST); } +%MOpts% { return handleSubstitution(MOPTS_SUBST); } +%WOpts% { return handleSubstitution(WOPTS_SUBST); } + +{Assembly} { return handleValueContext(ASSEMBLY); } +{Bytecode} { return handleValueContext(BYTECODE); } +{True} { return handleValueContext(TRUETOK); } +{False} { return handleValueContext(FALSETOK); } + +{Option} { ConfigLexerState.StringVal = yytext; return OPTION; } +{String} { ConfigLexerState.StringVal = yytext+1; // Nuke start quote + ConfigLexerState.StringVal.erase( + --ConfigLexerState.StringVal.end()); + return STRING; + } +{BadSubst} { YY_FATAL_ERROR("Invalid substitution token"); } + +%% |