Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dartagnan/src/main/antlr4/AsmArmLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ DataSynchronizationBarrier : 'dsb';
FenceArmOpt : 'sy' | 'st' | 'ish' | 'ishld' | 'ishst';


Literal : [a-z]+;
Literal : [a-zA-Z]+;
EndInstruction :'\\0A';
WS
: [ \t\r\n]+
Expand Down
2 changes: 1 addition & 1 deletion dartagnan/src/main/antlr4/AsmPPCLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ConstantValue : Num Numbers;
PPCFence : 'sync' | 'isync' | 'lwsync';

// misc
Literal : [a-z]+;
Literal : [a-zA-Z]+;
EndInstruction :'\\0A';
WS
: [ \t\r\n]+
Expand Down
2 changes: 1 addition & 1 deletion dartagnan/src/main/antlr4/AsmRISCVLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RISCVFence : 'fence';
TsoFence : 'tso';

// misc
Literal : [a-z]+;
Literal : [a-zA-Z]+;
EndInstruction :'\\0A';
WS
: [ \t\r\n]+
Expand Down
2 changes: 1 addition & 1 deletion dartagnan/src/main/antlr4/AsmX86Lexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ QCapitalLiteral : 'Q';
X86Fence : 'mfence';

// misc
Literal : [a-z]+;
Literal : [a-zA-Z]+;
EndInstruction :'\\0A';
WS
: [ \t\r\n]+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.misc.Interval;
import org.antlr.v4.runtime.tree.TerminalNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -376,7 +378,7 @@ public Expression visitCallInst(CallInstContext ctx) {
getOrNewRegister(currentRegisterName, returnType);

if (ctx.inlineAsm() != null) {
String asmCode = ctx.inlineAsm().inlineAsmBody().getText();
final String asmCode = ctx.inlineAsm().inlineAsmBody().getText();
// see https://llvm.org/docs/LangRef.html#inline-assembler-expressions
//FIXME ignore side effects of inline assembly
final List<ParserAsm> parsers = List.of(
Expand Down Expand Up @@ -412,7 +414,7 @@ public Expression visitCallInst(CallInstContext ctx) {
block.events.add(EventFactory.newNonDetChoice(resultRegister));
msg = "Setting non deterministic value.";
}
logger.warn("None of the parsers succeeded for inline assembly. {}", msg);
logger.warn("None of the parsers succeeded for inline assembly '{}'. {}", getSourceTextForContext(ctx), msg);
}
return resultRegister;
}
Expand Down Expand Up @@ -1440,6 +1442,19 @@ public Expression visitFilenameField(FilenameFieldContext ctx) {
// ----------------------------------------------------------------------------------------------------------------
// Helpers

// This method returns the original source code string associated to "ctx" including
// white spaces (ctx.getText() removes white spaces)
private String getSourceTextForContext(ParserRuleContext ctx) {
final Token startToken = (ctx.start instanceof TerminalNode start) ? start.getSymbol() : ctx.start;
final Token stopToken = (ctx.stop instanceof TerminalNode stop) ? stop.getSymbol() : ctx.stop;

final CharStream cs = startToken.getTokenSource().getInputStream();
final int startIndex = startToken.getStartIndex();
final int stopIndex = stopToken != null ? stopToken.getStopIndex() : -1;

return cs.getText(new Interval(startIndex, stopIndex));
}

private void check(boolean condition, String message, ParserRuleContext context) {
if (!condition) {
throw new ParsingException(String.format(message, context.getText()));
Expand Down
Loading