Search in sources :

Example 21 with TypeDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.

the class FatalError method Type.

TypeDescriptor Type() {
    TypeDescriptor typeDescriptor;
    typeDescriptor = null;
    if (isSubrange()) {
        typeDescriptor = SubrangeType();
    } else if (la.kind == 1) {
        Get();
        typeDescriptor = factory.getTypeDescriptor(t);
    } else if (la.kind == 6) {
        typeDescriptor = EnumDefinition();
    } else if (la.kind == 15 || la.kind == 16) {
        List<OrdinalDescriptor> ordinalDimensions = ArrayDefinition();
        while (continuesArray()) {
            Expect(13);
            List<OrdinalDescriptor> additionalDimensions = ArrayDefinition();
            ordinalDimensions.addAll(additionalDimensions);
        }
        Expect(13);
        Expect(1);
        typeDescriptor = factory.createArray(ordinalDimensions, t);
    } else if (la.kind == 14) {
        Get();
        Expect(13);
        OrdinalDescriptor ordinal = Ordinal();
        typeDescriptor = factory.createSetType(ordinal);
    } else if (la.kind == 19) {
        typeDescriptor = FileType();
    } else if (la.kind == 20) {
        typeDescriptor = RecordType();
    } else if (la.kind == 22) {
        typeDescriptor = PointerType();
    } else
        SynErr(65);
    return typeDescriptor;
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) List(java.util.List) ArrayList(java.util.ArrayList) OrdinalDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)

Example 22 with TypeDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.

the class FatalError method Ordinal.

OrdinalDescriptor Ordinal() {
    OrdinalDescriptor ordinal;
    ordinal = null;
    if (isSubrange()) {
        ordinal = SubrangeType();
    } else if (StartOf(3)) {
        TypeDescriptor typeDescriptor = Type();
        ordinal = factory.castTypeToOrdinalType(typeDescriptor);
    } else
        SynErr(74);
    return ordinal;
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) OrdinalDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)

Example 23 with TypeDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.

the class FatalError method RecordType.

TypeDescriptor RecordType() {
    TypeDescriptor typeDescriptor;
    Expect(21);
    factory.startRecord();
    typeDescriptor = RecordFieldList();
    Expect(22);
    factory.finishRecord();
    return typeDescriptor;
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)

Example 24 with TypeDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.

the class FatalError method EnumDefinition.

TypeDescriptor EnumDefinition() {
    TypeDescriptor typeDescriptor;
    List<String> enumIdentifiers = new ArrayList<>();
    Expect(6);
    Expect(1);
    enumIdentifiers.add(factory.getIdentifierFromToken(t));
    while (la.kind == 10) {
        Get();
        Expect(1);
        enumIdentifiers.add(factory.getIdentifierFromToken(t));
    }
    Expect(7);
    typeDescriptor = factory.registerEnum(enumIdentifiers);
    return typeDescriptor;
}
Also used : TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) ArrayList(java.util.ArrayList)

Example 25 with TypeDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor in project TrufflePascal by Aspect26.

the class BinaryExpressionNode method verifyChildrenNodeTypes.

@Override
public boolean verifyChildrenNodeTypes() {
    TypeDescriptor leftType = getLeftNode().getType();
    TypeDescriptor rightType = getRightNode().getType();
    if (this.typeTable.containsKey(new BinaryArgumentPrimitiveTypes(leftType, rightType))) {
        return true;
    }
    for (BinaryArgumentPrimitiveTypes allowedType : this.typeTable.keySet()) {
        TypeDescriptor allowedLeftType = allowedType.getLeftType();
        TypeDescriptor allowedRightType = allowedType.getRightType();
        if (leftType.convertibleTo(allowedLeftType) && rightType.convertibleTo(allowedRightType)) {
            return true;
        }
    }
    return this.verifyNonPrimitiveArgumentTypes(getLeftNode().getType(), getRightNode().getType());
}
Also used : BinaryArgumentPrimitiveTypes(cz.cuni.mff.d3s.trupple.language.nodes.utils.BinaryArgumentPrimitiveTypes) TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)

Aggregations

TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)50 LexicalException (cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException)9 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)7 TypeTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeTypeDescriptor)6 OrdinalDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)5 ArrayList (java.util.ArrayList)4 ArrayDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.ArrayDescriptor)3 EnumTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.EnumTypeDescriptor)3 RecordDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.RecordDescriptor)3 ReturnTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.ReturnTypeDescriptor)3 PointerDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.PointerDescriptor)2 ReferenceDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.ReferenceDescriptor)2 ConstantDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.constant.ConstantDescriptor)2 SubroutineDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.SubroutineDescriptor)2 List (java.util.List)2 StatementNode (cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)1 BinaryArgumentPrimitiveTypes (cz.cuni.mff.d3s.trupple.language.nodes.utils.BinaryArgumentPrimitiveTypes)1 PascalSubroutine (cz.cuni.mff.d3s.trupple.language.runtime.customvalues.PascalSubroutine)1 UnknownIdentifierException (cz.cuni.mff.d3s.trupple.parser.exceptions.UnknownIdentifierException)1 SetDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.SetDescriptor)1