use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class NodeFactory method registerRecordVariantTagVariable.
public void registerRecordVariantTagVariable(Token identifierToken, Token typeToken) {
String identifier = this.getIdentifierFromToken(identifierToken);
TypeDescriptor type = this.getTypeDescriptor(typeToken);
if (!(type instanceof OrdinalDescriptor)) {
parser.SemErr("Record variant selector must be of ordinal type");
}
try {
currentLexicalScope.registerLocalVariable(identifier, type);
} catch (LexicalException e) {
parser.SemErr(e.getMessage());
}
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class StringBuiltinUnit method importTo.
@Override
public void importTo(UnitLexicalScope scope) {
super.importTo(scope);
try {
scope.registerType("pchar", new PointerDescriptor(PCharDesriptor.getInstance()));
} catch (LexicalException e) {
throw new PascalRuntimeException("Could not import string unit: " + e.getMessage());
}
scope.markAllIdentifiersPublic();
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class LexicalScope method isSubroutineParameter.
boolean isSubroutineParameter(String identifier, int parameterIndex) throws LexicalException {
TypeDescriptor subroutineDescriptor = this.localIdentifiers.getIdentifierDescriptor(identifier);
if (!(subroutineDescriptor instanceof SubroutineDescriptor)) {
throw new LexicalException("Not a subroutine: " + identifier);
}
SubroutineDescriptor descriptor = (SubroutineDescriptor) subroutineDescriptor;
return descriptor.isSubroutineParameter(parameterIndex);
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class NodeFactory method addUnitFunctionInterface.
public void addUnitFunctionInterface(Token identifierToken, List<FormalParameter> formalParameters, Token returnTypeToken) {
String identifier = this.getIdentifierFromToken(identifierToken);
TypeDescriptor returnTypeDescriptor = this.getTypeDescriptor(returnTypeToken);
try {
currentLexicalScope.forwardFunction(identifier, formalParameters, returnTypeDescriptor);
} catch (LexicalException e) {
parser.SemErr(e.getMessage());
}
}
use of cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException in project TrufflePascal by Aspect26.
the class IdentifiersTable method addFunctionInterfaceIfNotForwarded.
public void addFunctionInterfaceIfNotForwarded(String identifier, List<FormalParameter> formalParameters, TypeDescriptor returnType) throws LexicalException {
TypeDescriptor descriptor = this.identifiersMap.get(identifier);
if (descriptor != null) {
if (!(descriptor instanceof FunctionDescriptor)) {
throw new LexicalException("Not a subroutine");
} else {
if (!SubroutineDescriptor.compareFormalParametersExact(((SubroutineDescriptor) descriptor).getFormalParameters(), formalParameters)) {
throw new LexicalException("Argument types mismatch");
}
}
return;
}
this.forwardFunction(identifier, formalParameters, returnType);
}
Aggregations