use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BallerinaParserErrorStrategy method reportUnwantedToken.
@Override
public void reportUnwantedToken(Parser parser) {
if (parser.getContext().exception != null || inErrorRecoveryMode(parser)) {
return;
}
beginErrorCondition(parser);
setContextException(parser);
Token token = parser.getCurrentToken();
DiagnosticPos pos = getPosition(getMissingSymbol(parser));
dlog.error(pos, DiagnosticCode.EXTRANEOUS_INPUT, getTokenErrorDisplay(token));
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class BallerinaParserErrorStrategy method reportInputMismatch.
@Override
public void reportInputMismatch(Parser parser, InputMismatchException e) {
setContextException(parser);
Token offendingToken = e.getOffendingToken();
String mismatchedToken = getTokenErrorDisplay(offendingToken);
String expectedToken = e.getExpectedTokens().toString(parser.getVocabulary());
DiagnosticPos pos = getPosition(offendingToken);
dlog.error(pos, DiagnosticCode.MISMATCHED_INPUT, mismatchedToken, expectedToken);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class CodeGenerator method addLineNumberInfo.
private void addLineNumberInfo(DiagnosticPos pos) {
LineNumberInfo lineNumInfo = createLineNumberInfo(pos, currentPkgInfo, currentPkgInfo.instructionList.size());
lineNoAttrInfo.addLineNumberInfo(lineNumInfo);
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class CodeGenerator method generateURILookupInstructions.
private void generateURILookupInstructions(Map<Name, BXMLNSSymbol> namespaces, RegIndex localNameRegIndex, RegIndex uriRegIndex, RegIndex targetQNameRegIndex, DiagnosticPos pos, SymbolEnv symbolEnv) {
if (namespaces.isEmpty()) {
createQNameWithoutPrefix(localNameRegIndex, uriRegIndex, targetQNameRegIndex);
return;
}
Stack<Operand> endJumpInstrStack = new Stack<>();
String prefix;
for (Entry<Name, BXMLNSSymbol> keyValues : namespaces.entrySet()) {
prefix = keyValues.getKey().getValue();
// skip the default namespace
if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
continue;
}
// Below section creates the condition to compare the namespace URIs
// store the comparing uri as string
BXMLNSSymbol nsSymbol = keyValues.getValue();
int opcode = getOpcode(TypeTags.STRING, InstructionCodes.IEQ);
RegIndex conditionExprIndex = getRegIndex(TypeTags.BOOLEAN);
emit(opcode, uriRegIndex, getNamespaceURIIndex(nsSymbol, symbolEnv), conditionExprIndex);
Operand ifCondJumpAddr = getOperand(-1);
emit(InstructionCodes.BR_FALSE, conditionExprIndex, ifCondJumpAddr);
// Below section creates instructions to be executed, if the above condition succeeds (then body)
// create the prefix literal
RegIndex prefixIndex = createStringLiteral(prefix, null, env);
// create a qname
emit(InstructionCodes.NEWQNAME, localNameRegIndex, uriRegIndex, prefixIndex, targetQNameRegIndex);
Operand endJumpAddr = getOperand(-1);
emit(InstructionCodes.GOTO, endJumpAddr);
endJumpInstrStack.add(endJumpAddr);
ifCondJumpAddr.value = nextIP();
}
// else part. create a qname with empty prefix
createQNameWithoutPrefix(localNameRegIndex, uriRegIndex, targetQNameRegIndex);
while (!endJumpInstrStack.isEmpty()) {
endJumpInstrStack.pop().value = nextIP();
}
}
use of org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos in project ballerina by ballerina-lang.
the class ASTBuilderUtil method createVariableDef.
static BLangVariableDef createVariableDef(DiagnosticPos pos) {
final BLangVariableDef variableDef = (BLangVariableDef) TreeBuilder.createVariableDefinitionNode();
variableDef.pos = pos;
return variableDef;
}
Aggregations