/*===-- 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.
//
#define RET_TOK(type, Enum, sym) \
llvmAsmlval.type = Instruction::Enum; return sym
+namespace llvm {
// TODO: All of the static identifiers are figured out by the lexer,
// these should be hashed to reduce the lexer size
return BOut;
}
+} // End llvm namespace
+
+using namespace llvm;
+
#define YY_NEVER_INTERACTIVE 1
%}
begin { return BEGINTOK; }
end { return ENDTOK; }
-true { return TRUE; }
-false { return FALSE; }
+true { return TRUETOK; }
+false { return FALSETOK; }
declare { return DECLARE; }
global { return GLOBAL; }
constant { return CONSTANT; }
-const { return CONST; }
internal { return INTERNAL; }
linkonce { return LINKONCE; }
weak { return WEAK; }
implementation { return IMPLEMENTATION; }
zeroinitializer { return ZEROINITIALIZER; }
\.\.\. { return DOTDOTDOT; }
+undef { return UNDEF; }
null { return NULL_TOK; }
to { return TO; }
-except { return EXCEPT; }
+except { RET_TOK(TermOpVal, Unwind, UNWIND); }
not { return NOT; } /* Deprecated, turned into XOR */
target { return TARGET; }
+triple { return TRIPLE; }
+deplibs { return DEPLIBS; }
endian { return ENDIAN; }
pointersize { return POINTERSIZE; }
little { return LITTLE; }
ulong { llvmAsmlval.PrimType = Type::ULongTy ; return ULONG; }
float { llvmAsmlval.PrimType = Type::FloatTy ; return FLOAT; }
double { llvmAsmlval.PrimType = Type::DoubleTy; return DOUBLE; }
-type { llvmAsmlval.PrimType = Type::TypeTy ; return TYPE; }
label { llvmAsmlval.PrimType = Type::LabelTy ; return LABEL; }
+type { return TYPE; }
opaque { return OPAQUE; }
add { RET_TOK(BinaryOpVal, Add, ADD); }
setle { RET_TOK(BinaryOpVal, SetLE, SETLE); }
setge { RET_TOK(BinaryOpVal, SetGE, SETGE); }
-phi { RET_TOK(OtherOpVal, PHINode, PHI); }
+phi { RET_TOK(OtherOpVal, PHI, PHI_TOK); }
call { RET_TOK(OtherOpVal, Call, CALL); }
cast { RET_TOK(OtherOpVal, Cast, CAST); }
+select { RET_TOK(OtherOpVal, Select, SELECT); }
shl { RET_TOK(OtherOpVal, Shl, SHL); }
shr { RET_TOK(OtherOpVal, Shr, SHR); }
va_arg { return VA_ARG; /* FIXME: OBSOLETE */}
switch { RET_TOK(TermOpVal, Switch, SWITCH); }
invoke { RET_TOK(TermOpVal, Invoke, INVOKE); }
unwind { RET_TOK(TermOpVal, Unwind, UNWIND); }
-
+unreachable { RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
malloc { RET_TOK(MemOpVal, Malloc, MALLOC); }
alloca { RET_TOK(MemOpVal, Alloca, ALLOCA); }
{FPConstant} { llvmAsmlval.FPVal = atof(yytext); return FPVAL; }
{HexFPConstant} { llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; }
-[ \t\n] { /* Ignore whitespace */ }
+<<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]; }
%%