Search in sources :

Example 6 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method CaseList.

CaseStatementData CaseList() {
    CaseStatementData data;
    data = new CaseStatementData();
    ExpressionNode caseConstant = Expression();
    data.indexNodes.add(caseConstant);
    Expect(24);
    StatementNode caseStatement = Statement();
    data.statementNodes.add(caseStatement);
    while (!caseEnds()) {
        Expect(8);
        caseConstant = Expression();
        data.indexNodes.add(caseConstant);
        Expect(24);
        caseStatement = Statement();
        data.statementNodes.add(caseStatement);
    }
    if (la.kind == 8) {
        Get();
    }
    if (la.kind == 36) {
        Get();
        data.elseNode = Statement();
    }
    if (la.kind == 8) {
        Get();
    }
    return data;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 7 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method ForLoop.

StatementNode ForLoop() {
    StatementNode statement;
    factory.startLoop();
    Expect(39);
    boolean ascending = true;
    Expect(1);
    Token variableToken = t;
    Expect(35);
    ExpressionNode startValue = Expression();
    if (la.kind == 40) {
        Get();
        ascending = true;
    } else if (la.kind == 41) {
        Get();
        ascending = false;
    } else
        SynErr(74);
    ExpressionNode finalValue = Expression();
    Expect(38);
    StatementNode loopBody = Statement();
    statement = factory.createForLoop(ascending, variableToken, startValue, finalValue, loopBody);
    factory.finishLoop();
    return statement;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 8 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method Statement.

StatementNode Statement() {
    StatementNode statement;
    statement = null;
    Token label = null;
    if (la.kind == 3) {
        label = Label();
        Expect(24);
    }
    switch(la.kind) {
        case 8:
        case 21:
        case 36:
        case 43:
            {
                statement = factory.createNopStatement();
                break;
            }
        case 45:
            {
                statement = IfStatement();
                break;
            }
        case 39:
            {
                statement = ForLoop();
                break;
            }
        case 44:
            {
                statement = WhileLoop();
                break;
            }
        case 42:
            {
                statement = RepeatLoop();
                break;
            }
        case 23:
            {
                statement = CaseStatement();
                break;
            }
        case 37:
            {
                statement = WithStatement();
                break;
            }
        case 47:
            {
                statement = GotoStatement();
                break;
            }
        case 34:
            {
                statement = Block();
                break;
            }
        case 1:
            {
                statement = IdentifierBeginningStatement();
                break;
            }
        default:
            SynErr(73);
            break;
    }
    if (label != null)
        statement = factory.createLabeledStatement(statement, label);
    return statement;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 9 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method WithStatement.

StatementNode WithStatement() {
    StatementNode statement;
    Expect(39);
    List<String> recordIdentifiers = IdentifiersList();
    LexicalScope initialScope = factory.getScope();
    List<FrameSlot> recordSlots = factory.stepIntoRecordsScope(recordIdentifiers);
    Expect(40);
    StatementNode innerStatement = Statement();
    factory.setScope(initialScope);
    statement = factory.createWithStatement(recordSlots, innerStatement);
    return statement;
}
Also used : FrameSlot(com.oracle.truffle.api.frame.FrameSlot) StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Example 10 with StatementNode

use of cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode in project TrufflePascal by Aspect26.

the class FatalError method CaseStatement.

StatementNode CaseStatement() {
    StatementNode statement;
    Expect(24);
    ExpressionNode caseExpression = Expression();
    Expect(14);
    CaseStatementData caseData = CaseList();
    caseData.caseExpression = caseExpression;
    Expect(22);
    statement = factory.createCaseStatement(caseData);
    return statement;
}
Also used : StatementNode(cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)

Aggregations

StatementNode (cz.cuni.mff.d3s.trupple.language.nodes.statement.StatementNode)30 ArrayList (java.util.ArrayList)6 FrameSlot (com.oracle.truffle.api.frame.FrameSlot)2 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1 BlockNode (cz.cuni.mff.d3s.trupple.language.nodes.statement.BlockNode)1 TypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.TypeDescriptor)1 EnumTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.compound.EnumTypeDescriptor)1 ReturnTypeDescriptor (cz.cuni.mff.d3s.trupple.parser.identifierstable.types.subroutine.ReturnTypeDescriptor)1