for (char *BIn = Buffer; *BIn; ) {
if (BIn[0] == '\\' && isxdigit(BIn[1]) && isxdigit(BIn[2])) {
char Tmp = BIn[3]; BIn[3] = 0; // Terminate string
- *BOut = strtol(BIn+1, 0, 16); // Convert to number
+ *BOut = (char)strtol(BIn+1, 0, 16); // Convert to number
if (!AllowNull && !*BOut)
ThrowException("String literal cannot accept \\00 escape!");
/* Label identifiers end with a colon */
Label [-a-zA-Z$._0-9]+:
+QuoteLabel \"[^\"]+\":
/* Quoted names can contain any character except " and \ */
StringConstant \"[^\"]*\"
to { return TO; }
except { RET_TOK(TermOpVal, Unwind, UNWIND); }
not { return NOT; } /* Deprecated, turned into XOR */
+tail { return TAIL; }
target { return TARGET; }
triple { return TRIPLE; }
deplibs { return DEPLIBS; }
big { return BIG; }
volatile { return VOLATILE; }
+cc { return CC_TOK; }
+ccc { return CCC_TOK; }
+fastcc { return FASTCC_TOK; }
+coldcc { return COLDCC_TOK; }
+
void { llvmAsmlval.PrimType = Type::VoidTy ; return VOID; }
bool { llvmAsmlval.PrimType = Type::BoolTy ; return BOOL; }
sbyte { llvmAsmlval.PrimType = Type::SByteTy ; return SBYTE; }
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 */}
vanext { RET_TOK(OtherOpVal, VANext, VANEXT); }
vaarg { RET_TOK(OtherOpVal, VAArg , VAARG); }
llvmAsmlval.StrVal = strdup(yytext);
return LABELSTR;
}
+{QuoteLabel} {
+ yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
+ UnEscapeLexed(yytext+1);
+ llvmAsmlval.StrVal = strdup(yytext+1);
+ return LABELSTR;
+ }
{StringConstant} { // Note that we cannot unescape a string constant here! The
// string constant might contain a \00 which would not be
return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
}
-{EPInteger} { llvmAsmlval.UIntVal = atoull(yytext+1); return UINTVAL; }
+{EPInteger} {
+ uint64_t Val = atoull(yytext+1);
+ if ((unsigned)Val != Val)
+ ThrowException("Invalid value number (too large)!");
+ llvmAsmlval.UIntVal = unsigned(Val);
+ return UINTVAL;
+ }
{ENInteger} {
uint64_t Val = atoull(yytext+2);
// +1: we have bigger negative range
if (Val > (uint64_t)INT32_MAX+1)
ThrowException("Constant too large for signed 32 bits!");
- llvmAsmlval.SIntVal = -Val;
+ llvmAsmlval.SIntVal = (int)-Val;
return SINTVAL;
}