diff options
Diffstat (limited to 'tools/llvm-upgrade/UpgradeLexer.l.cvs')
-rw-r--r-- | tools/llvm-upgrade/UpgradeLexer.l.cvs | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/tools/llvm-upgrade/UpgradeLexer.l.cvs b/tools/llvm-upgrade/UpgradeLexer.l.cvs new file mode 100644 index 0000000..08dfd8f --- /dev/null +++ b/tools/llvm-upgrade/UpgradeLexer.l.cvs @@ -0,0 +1,229 @@ +/*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the flex scanner for LLVM assembly languages files. +// +//===----------------------------------------------------------------------===*/ + +%option prefix="Upgrade" +%option yylineno +%option nostdinit +%option never-interactive +%option batch +%option noyywrap +%option nodefault +%option 8bit +%option outfile="UpgradeLexer.cpp" +%option ecs +%option noreject +%option noyymore + +%{ + +#include "ParserInternals.h" +#define YYSTYPE std::string* +#include "UpgradeParser.h" +#include <cctype> +#include <cstdlib> + +void set_scan_bytes (const char * str, size_t len) { + Upgrade_scan_bytes (str, len); +} + +static void trim(std::string& str) { + size_t startpos = str.find_first_not_of(" \t\n\r",0); + if (startpos != std::string::npos) + str.erase(0,startpos); +} + +// Construct a token value for a non-obsolete token +#define RET_TOK(sym) \ + Upgradelval = new std::string(yytext); \ + trim(*Upgradelval); \ + return sym + +#define YY_NEVER_INTERACTIVE 1 +%} + + + +/* Comments start with a ; and go till end of line */ +Comment ;.* + +/* Variable(Value) identifiers start with a % sign */ +VarID %[-a-zA-Z$._][-a-zA-Z$._0-9]* + +/* Label identifiers end with a colon */ +Label [-a-zA-Z$._0-9]+: +QuoteLabel \"[^\"]+\": + +/* Quoted names can contain any character except " and \ */ +StringConstant \"[^\"]*\" + + +/* [PN]Integer: match positive and negative literal integer values that + * are preceeded by a '%' character. These represent unnamed variable slots. + */ +EPInteger %[0-9]+ +ENInteger %-[0-9]+ + + +/* E[PN]Integer: match positive and negative literal integer values */ +PInteger [0-9]+ +NInteger -[0-9]+ + +/* FPConstant - A Floating point constant. + */ +FPConstant [-+]?[0-9]+[.][0-9]*([eE][-+]?[0-9]+)? + +/* HexFPConstant - Floating point constant represented in IEEE format as a + * hexadecimal number for when exponential notation is not precise enough. + */ +HexFPConstant 0x[0-9A-Fa-f]+ + +/* HexIntConstant - Hexadecimal constant generated by the CFE to avoid forcing + * it to deal with 64 bit numbers. + */ +HexIntConstant [us]0x[0-9A-Fa-f]+ +%% + +{Comment} { /* Ignore comments for now */ } + +begin { RET_TOK( BEGINTOK); } +end { RET_TOK( ENDTOK); } +true { RET_TOK( TRUETOK); } +false { RET_TOK( FALSETOK); } +declare { RET_TOK( DECLARE); } +global { RET_TOK( GLOBAL); } +constant { RET_TOK( CONSTANT); } +internal { RET_TOK( INTERNAL); } +linkonce { RET_TOK( LINKONCE); } +weak { RET_TOK( WEAK); } +appending { RET_TOK( APPENDING); } +dllimport { RET_TOK( DLLIMPORT); } +dllexport { RET_TOK( DLLEXPORT); } +extern_weak { RET_TOK( EXTERN_WEAK); } +external { RET_TOK( EXTERNAL); } +implementation { RET_TOK( IMPLEMENTATION); } +zeroinitializer { RET_TOK( ZEROINITIALIZER); } +\.\.\. { RET_TOK( DOTDOTDOT); } +undef { RET_TOK( UNDEF); } +null { RET_TOK( NULL_TOK); } +to { RET_TOK( TO); } +tail { RET_TOK( TAIL); } +target { RET_TOK( TARGET); } +triple { RET_TOK( TRIPLE); } +deplibs { RET_TOK( DEPLIBS); } +endian { RET_TOK( ENDIAN); } +pointersize { RET_TOK( POINTERSIZE); } +datalayout { RET_TOK( DATALAYOUT); } +little { RET_TOK( LITTLE); } +big { RET_TOK( BIG); } +volatile { RET_TOK( VOLATILE); } +align { RET_TOK( ALIGN); } +section { RET_TOK( SECTION); } +module { RET_TOK( MODULE); } +asm { RET_TOK( ASM_TOK); } +sideeffect { RET_TOK( SIDEEFFECT); } + +cc { RET_TOK( CC_TOK); } +ccc { RET_TOK( CCC_TOK); } +csretcc { RET_TOK( CSRETCC_TOK); } +fastcc { RET_TOK( FASTCC_TOK); } +coldcc { RET_TOK( COLDCC_TOK); } +x86_stdcallcc { RET_TOK( X86_STDCALLCC_TOK); } +x86_fastcallcc { RET_TOK( X86_FASTCALLCC_TOK); } + +void { RET_TOK( VOID); } +bool { RET_TOK( BOOL); } +sbyte { RET_TOK( SBYTE); } +ubyte { RET_TOK( UBYTE); } +short { RET_TOK( SHORT); } +ushort { RET_TOK( USHORT); } +int { RET_TOK( INT); } +uint { RET_TOK( UINT); } +long { RET_TOK( LONG); } +ulong { RET_TOK( ULONG); } +float { RET_TOK( FLOAT); } +double { RET_TOK( DOUBLE); } +label { RET_TOK( LABEL); } +type { RET_TOK( TYPE); } +opaque { RET_TOK( OPAQUE); } + +add { RET_TOK( ADD); } +sub { RET_TOK( SUB); } +mul { RET_TOK( MUL); } +div { RET_TOK( UDIV); } +udiv { RET_TOK( UDIV); } +sdiv { RET_TOK( SDIV); } +fdiv { RET_TOK( FDIV); } +rem { RET_TOK( UREM); } +urem { RET_TOK( UREM); } +srem { RET_TOK( SREM); } +frem { RET_TOK( FREM); } +and { RET_TOK( AND); } +or { RET_TOK( OR); } +xor { RET_TOK( XOR); } +setne { RET_TOK( SETNE); } +seteq { RET_TOK( SETEQ); } +setlt { RET_TOK( SETLT); } +setgt { RET_TOK( SETGT); } +setle { RET_TOK( SETLE); } +setge { RET_TOK( SETGE); } + +phi { RET_TOK( PHI_TOK); } +call { RET_TOK( CALL); } +cast { RET_TOK( TRUNC); } +select { RET_TOK( SELECT); } +shl { RET_TOK( SHL); } +lshr { RET_TOK( LSHR); } +ashr { RET_TOK( ASHR); } +va_arg { RET_TOK( VAARG); } +ret { RET_TOK( RET); } +br { RET_TOK( BR); } +switch { RET_TOK( SWITCH); } +invoke { RET_TOK( INVOKE); } +unwind { RET_TOK( UNWIND); } +unreachable { RET_TOK( UNREACHABLE); } + +malloc { RET_TOK( MALLOC); } +alloca { RET_TOK( ALLOCA); } +free { RET_TOK( FREE); } +load { RET_TOK( LOAD); } +store { RET_TOK( STORE); } +getelementptr { RET_TOK( GETELEMENTPTR); } + +extractelement { RET_TOK( EXTRACTELEMENT); } +insertelement { RET_TOK( INSERTELEMENT); } +shufflevector { RET_TOK( SHUFFLEVECTOR); } + + +{VarID} { RET_TOK( VAR_ID); } +{Label} { RET_TOK( LABELSTR); } +{QuoteLabel} { RET_TOK( LABELSTR); } +{StringConstant} { RET_TOK( STRINGCONSTANT ); } +{PInteger} { RET_TOK( EUINT64VAL ); } +{NInteger} { RET_TOK( ESINT64VAL ); } +{HexIntConstant} { RET_TOK( yytext[0] == 's' ? ESINT64VAL : EUINT64VAL ); } +{EPInteger} { RET_TOK( UINTVAL); } +{ENInteger} { RET_TOK( SINTVAL); } +{FPConstant} { RET_TOK( FPVAL); } +{HexFPConstant} { RET_TOK( FPVAL); } +<<EOF>> { + /* Make sure to free the internal buffers for flex when we are + * done reading our input! + */ + yy_delete_buffer(YY_CURRENT_BUFFER); + return EOF; + } + +[ \r\t\n] { /* Ignore whitespace */ } +. { return yytext[0]; } + +%% |