use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class IdentifiersTable method addProcedureInterfaceIfNotForwarded.
public void addProcedureInterfaceIfNotForwarded(String identifier, List<FormalParameter> formalParameters) throws LexicalException {
TypeDescriptor descriptor = this.identifiersMap.get(identifier);
if (descriptor != null) {
if (!(descriptor instanceof ProcedureDescriptor)) {
throw new LexicalException("Not a subroutine");
} else {
if (!SubroutineDescriptor.compareFormalParametersExact(((SubroutineDescriptor) descriptor).getFormalParameters(), formalParameters)) {
throw new LexicalException("Argument types mismatch");
}
}
return;
}
this.forwardProcedure(identifier, formalParameters);
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class NodeFactory method startUnitFunctionImplementation.
public void startUnitFunctionImplementation(FunctionHeading heading) {
String identifier = this.getIdentifierFromToken(heading.identifierToken);
TypeDescriptor returnTypeDescriptor = heading.returnTypeDescriptor;
try {
if (currentLexicalScope.containsLocalIdentifier(identifier) && !currentLexicalScope.isSubroutine(identifier)) {
parser.SemErr("Cannot implement. Not a function: " + identifier);
} else if (!currentLexicalScope.containsLocalIdentifier(identifier)) {
currentLexicalScope.forwardFunction(identifier, heading.formalParameters, returnTypeDescriptor);
}
currentLexicalScope = new LexicalScope(currentLexicalScope, identifier, parser.isUsingTPExtension());
currentLexicalScope.registerReturnVariable(currentLexicalScope.getName(), returnTypeDescriptor);
this.addParameterIdentifiersToLexicalScope(heading.formalParameters);
} catch (LexicalException e) {
parser.SemErr(e.getMessage());
}
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class IdentifiersTableTP method addBuiltinFunctions.
@Override
protected void addBuiltinFunctions() {
super.addBuiltinFunctions();
try {
this.registerNewIdentifier("random", new RandomSubroutineDescriptor());
this.registerNewIdentifier("randomize", new RandomizeSubroutineDescriptor());
this.registerNewIdentifier("assign", new AssignSubroutineDescriptor());
} catch (LexicalException e) {
throw new PascalRuntimeException("Could not initialize extension builtin functions: " + e.getMessage());
}
}
Aggregations