SMLoc S = getLoc();
SMLoc E;
- if (getLexer().getKind() != AsmToken::Percent) {
- Error(getLoc(), "expected '%' for operand modifier");
+ if (parseToken(AsmToken::Percent, "expected '%' for operand modifier"))
return MatchOperand_ParseFail;
- }
-
- getParser().Lex(); // Eat '%'
if (getLexer().getKind() != AsmToken::Identifier) {
Error(getLoc(), "expected valid identifier for operand modifier");
}
getParser().Lex(); // Eat the identifier
- if (getLexer().getKind() != AsmToken::LParen) {
- Error(getLoc(), "expected '('");
+ if (parseToken(AsmToken::LParen, "expected '('"))
return MatchOperand_ParseFail;
- }
- getParser().Lex(); // Eat '('
const MCExpr *SubExpr;
if (getParser().parseParenExpression(SubExpr, E)) {
OperandMatchResultTy
RISCVAsmParser::parseMemOpBaseReg(OperandVector &Operands) {
- if (getLexer().isNot(AsmToken::LParen)) {
- Error(getLoc(), "expected '('");
+ if (parseToken(AsmToken::LParen, "expected '('"))
return MatchOperand_ParseFail;
- }
-
- getParser().Lex(); // Eat '('
Operands.push_back(RISCVOperand::createToken("(", getLoc()));
if (parseRegister(Operands) != MatchOperand_Success) {
return MatchOperand_ParseFail;
}
- if (getLexer().isNot(AsmToken::RParen)) {
- Error(getLoc(), "expected ')'");
+ if (parseToken(AsmToken::RParen, "expected ')'"))
return MatchOperand_ParseFail;
- }
-
- getParser().Lex(); // Eat ')'
Operands.push_back(RISCVOperand::createToken(")", getLoc()));
return MatchOperand_Success;
ImmStart, ImmEnd, isRV64());
}
- if (getLexer().isNot(AsmToken::LParen)) {
- Error(getLoc(), OptionalImmOp ? "expected '(' after optional integer offset"
- : "expected '(' or optional integer offset");
+ if (parseToken(AsmToken::LParen,
+ OptionalImmOp ? "expected '(' after optional integer offset"
+ : "expected '(' or optional integer offset"))
return MatchOperand_ParseFail;
- }
- getParser().Lex(); // Eat '('
if (parseRegister(Operands) != MatchOperand_Success) {
Error(getLoc(), "expected register");
return MatchOperand_ParseFail;
}
- if (getLexer().isNot(AsmToken::RParen)) {
- Error(getLoc(), "expected ')'");
+ if (parseToken(AsmToken::RParen, "expected ')'"))
return MatchOperand_ParseFail;
- }
- getParser().Lex(); // Eat ')'
// Deferred Handling of non-zero offsets. This makes the error messages nicer.
if (OptionalImmOp && !OptionalImmOp->isImmZero()) {
return true;
}
- if (getLexer().isNot(AsmToken::EndOfStatement)) {
- SMLoc Loc = getLexer().getLoc();
+ if (getParser().parseEOL("unexpected token")) {
getParser().eatToEndOfStatement();
- return Error(Loc, "unexpected token");
+ return true;
}
-
- getParser().Lex(); // Consume the EndOfStatement.
return false;
}