Search in sources :

Example 16 with Statement

use of st.gravel.support.compiler.ast.Statement in project gravel by gravel-st.

the class SequenceNode method methodSourceOn_.

public SequenceNode methodSourceOn_(final StringBuilder _aStream) {
    this.sourceTemporariesOn_(_aStream);
    boolean _temp1 = true;
    for (final Statement _stmt : _statements) {
        if (_temp1) {
            _temp1 = false;
        } else {
            _aStream.append('.');
        }
        _aStream.append('\n');
        _aStream.append('\t');
        _stmt.innerSourceOn_(_aStream);
    }
    return this;
}
Also used : Statement(st.gravel.support.compiler.ast.Statement)

Example 17 with Statement

use of st.gravel.support.compiler.ast.Statement in project gravel by gravel-st.

the class SequenceNode method sourceOn_.

@Override
public SequenceNode sourceOn_(final StringBuilder _aStream) {
    this.sourceTemporariesOn_(_aStream);
    if ((_temporaries.length != 0) && (_statements.length != 0)) {
        _aStream.append('\n');
    }
    boolean _temp1 = true;
    for (final Statement _stmt : _statements) {
        if (_temp1) {
            _temp1 = false;
        } else {
            _aStream.append('.');
            _aStream.append('\n');
        }
        _aStream.append(' ');
        _stmt.innerSourceOn_(_aStream);
    }
    return this;
}
Also used : Statement(st.gravel.support.compiler.ast.Statement)

Example 18 with Statement

use of st.gravel.support.compiler.ast.Statement in project gravel by gravel-st.

the class SourcePrinter method printStatements_indent_.

public SourcePrinter printStatements_indent_(final Statement[] _stmts, final boolean _aBoolean) {
    final int _show;
    Statement _thisStatement;
    boolean _indent;
    _indent = _aBoolean;
    _show = _stmts.length;
    for (int _i = 1; _i <= _show; _i++) {
        _thisStatement = _stmts[_i - 1];
        if ((_thisStatement.comment().length > 0)) {
            if (st.gravel.support.jvm.IntegerExtensions.equals_(_i, 1)) {
                SourcePrinter.this.crtab_(_indentation);
            }
            _stream.append('\t');
        }
        if (_indent) {
            SourcePrinter.this.crtab_(_indentation);
        }
        SourcePrinter.this.visit_(_thisStatement);
        if ((_i < _show)) {
            _stream.append('.');
        }
        _indent = true;
    }
    return this;
}
Also used : IntermediateStatement(st.gravel.support.compiler.ast.IntermediateStatement) Statement(st.gravel.support.compiler.ast.Statement)

Example 19 with Statement

use of st.gravel.support.compiler.ast.Statement in project gravel by gravel-st.

the class MessageSendRewriter method visitKeywordMessageNode_.

@Override
public Statement visitKeywordMessageNode_(final KeywordMessageNode _anObject) {
    final st.gravel.core.Symbol _selector;
    final st.gravel.support.jvm.Block1<Statement, MessageNode> _res;
    _selector = st.gravel.core.Symbol.value(_anObject.selector());
    st.gravel.support.jvm.Block1<Statement, MessageNode> _temp1 = _specialSelectors.get(_selector);
    _res = ((st.gravel.support.jvm.Block1<Statement, MessageNode>) _temp1);
    if (_res != null) {
        final Statement _trans;
        _trans = _res.value_(_anObject);
        if (_trans != null) {
            return _trans;
        }
    }
    return super.visitKeywordMessageNode_(_anObject);
}
Also used : BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) MessageNode(st.gravel.support.compiler.ast.MessageNode) UnaryMessageNode(st.gravel.support.compiler.ast.UnaryMessageNode) KeywordMessageNode(st.gravel.support.compiler.ast.KeywordMessageNode) Statement(st.gravel.support.compiler.ast.Statement)

Example 20 with Statement

use of st.gravel.support.compiler.ast.Statement in project gravel by gravel-st.

the class Parser method parseSequenceNode_.

public SequenceNode parseSequenceNode_(final st.gravel.support.jvm.Block1<Object, PragmaNode[]> _extraPragmaBlock) {
    VariableDeclarationNode[] _temporaries;
    Statement[] _statements;
    Statement _statement;
    final int _start;
    final PragmaNode[] _pragmas;
    _start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
    this.eatWhitespace();
    _temporaries = new VariableDeclarationNode[] {};
    if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|')) {
        Parser.this.eatWhitespace();
        boolean _temp1 = false;
        while (!_temp1) {
            _temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|');
            if (!_temp1) {
                Parser.this.eatWhitespace();
                _temporaries = st.gravel.support.jvm.ArrayExtensions.copyWith_(_temporaries, Parser.this.parseVariableDeclaration());
                Parser.this.eatWhitespace();
            }
        }
    }
    _pragmas = this.readPragmas();
    if (_pragmas.length != 0) {
        _extraPragmaBlock.value_(_pragmas);
    }
    _statements = new Statement[] {};
    _statement = this.parseStatement();
    this.eatWhitespace();
    boolean _temp2 = false;
    while (!_temp2) {
        _temp2 = _statement == null;
        if (!_temp2) {
            _statements = st.gravel.support.jvm.ArrayExtensions.copyWith_(_statements, _statement);
            st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '.');
            _statement = Parser.this.parseStatement();
            Parser.this.eatWhitespace();
        }
    }
    return ((SequenceNode) this.setSourcePosition_node_(_start, SequenceNode.factory.temporaries_statements_(_temporaries, _statements)));
}
Also used : PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) Statement(st.gravel.support.compiler.ast.Statement)

Aggregations

Statement (st.gravel.support.compiler.ast.Statement)34 Test (org.junit.Test)21 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)5 BinaryMessageNode (st.gravel.support.compiler.ast.BinaryMessageNode)3 Expression (st.gravel.support.compiler.ast.Expression)3 KeywordMessageNode (st.gravel.support.compiler.ast.KeywordMessageNode)3 MessageNode (st.gravel.support.compiler.ast.MessageNode)3 UnaryMessageNode (st.gravel.support.compiler.ast.UnaryMessageNode)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IntermediateStatement (st.gravel.support.compiler.ast.IntermediateStatement)1 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)1 TypeNode (st.gravel.support.compiler.ast.TypeNode)1 VariableNode (st.gravel.support.compiler.ast.VariableNode)1 VariableScopeAnalyzerState (st.gravel.support.compiler.ast.VariableScopeAnalyzerState)1