Search in sources :

Example 1 with OrdinalDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor 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());
    }
}
Also used : LexicalException(cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException) TypeDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor) OrdinalDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)

Example 2 with OrdinalDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor 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 3 with OrdinalDescriptor

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

the class FatalError method RecordVariantSelector.

OrdinalDescriptor RecordVariantSelector() {
    OrdinalDescriptor selectorDescriptor;
    Token tagToken = null;
    if (isVariantSelectorTag()) {
        Expect(1);
        tagToken = t;
        Expect(24);
    }
    Expect(1);
    if (tagToken != null)
        factory.registerRecordVariantTagVariable(tagToken, t);
    selectorDescriptor = factory.castTypeToOrdinalType(factory.getTypeDescriptor(t));
    return selectorDescriptor;
}
Also used : OrdinalDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)

Example 4 with OrdinalDescriptor

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

the class FatalError method ArrayDefinition.

List<OrdinalDescriptor> ArrayDefinition() {
    List<OrdinalDescriptor> ordinalDimensions;
    if (la.kind == 15) {
        Get();
    }
    Expect(16);
    ordinalDimensions = new ArrayList<>();
    Expect(17);
    OrdinalDescriptor ordinalDescriptor = null;
    ordinalDescriptor = Ordinal();
    ordinalDimensions.add(ordinalDescriptor);
    while (la.kind == 10) {
        Get();
        ordinalDescriptor = Ordinal();
        ordinalDimensions.add(ordinalDescriptor);
    }
    Expect(18);
    return ordinalDimensions;
}
Also used : OrdinalDescriptor(cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)

Example 5 with OrdinalDescriptor

use of cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor 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)

Aggregations

OrdinalDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.complex.OrdinalDescriptor)13 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)5 ConstantDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.constant.ConstantDescriptor)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 LexicalException (cz.cuni.mff.d3s.trupple.parser.exceptions.LexicalException)1