* Add entry for Linux/PowerPC
[oota-llvm.git] / lib / AsmParser / Lexer.l
index f0f007b4b3a1fb6ad59940d12dc50198853a7ea9..072bc159d837afd50a067c14896b38b26cb4628e 100644 (file)
@@ -1,4 +1,11 @@
 /*===-- 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.
 //
@@ -28,6 +35,7 @@
 #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
@@ -114,6 +122,10 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull) {
   return BOut;
 }
 
+} // End llvm namespace
+
+using namespace llvm;
+
 #define YY_NEVER_INTERACTIVE 1
 %}
 
@@ -162,12 +174,11 @@ HexIntConstant [us]0x[0-9A-Fa-f]+
 
 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; }
@@ -177,11 +188,14 @@ external        { return EXTERNAL; }
 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; }
@@ -200,8 +214,8 @@ long            { llvmAsmlval.PrimType = Type::LongTy  ; return LONG;   }
 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); }
@@ -219,9 +233,10 @@ setgt           { RET_TOK(BinaryOpVal, SetGT, SETGT); }
 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 */}
@@ -233,7 +248,7 @@ br              { RET_TOK(TermOpVal, Br, BR); }
 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); }
@@ -293,7 +308,15 @@ getelementptr   { RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
 {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]; }
 
 %%