Search in sources :

Example 11 with Expression

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

the class Parser method parseMessageChain_.

public Expression parseMessageChain_(final Expression _receiver) {
    final Expression _exp;
    List<MessageNode> _messages;
    _exp = this.parseNoCascadeMessageChain_(_receiver);
    this.eatWhitespace();
    if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ';')) {
        final MessageNode _baseMsg;
        _messages = new java.util.ArrayList();
        _baseMsg = ((MessageNode) _exp);
        _messages.add(_baseMsg);
        boolean _temp1 = true;
        while (_temp1) {
            final MessageNode _msg;
            _msg = ((MessageNode) Parser.this.parseNoCascadeMessageChain_(_baseMsg.receiver()));
            _messages.add(_msg);
            _temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ';');
        }
        return CascadeNode.factory.messages_(_messages.toArray(new MessageNode[_messages.size()]));
    }
    return _exp;
}
Also used : Expression(st.gravel.support.compiler.ast.Expression) MessageNode(st.gravel.support.compiler.ast.MessageNode) UnaryMessageNode(st.gravel.support.compiler.ast.UnaryMessageNode) KeywordMessageNode(st.gravel.support.compiler.ast.KeywordMessageNode) BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) ArrayList(java.util.ArrayList)

Example 12 with Expression

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

the class Parser method parseAssignmentOrExpression.

public Expression parseAssignmentOrExpression() {
    final Expression _rec;
    final int _start;
    _start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
    _rec = this.parseExpression();
    this.eatWhitespace();
    if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':')) {
        st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '='));
        return ((Expression) Parser.this.setSourcePosition_node_(_start, Parser.this.parseAssignment_(_rec)));
    }
    return ((Expression) this.setSourcePosition_node_(_start, _rec));
}
Also used : Expression(st.gravel.support.compiler.ast.Expression)

Example 13 with Expression

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

the class Parser method parseNestedExpression.

public Expression parseNestedExpression() {
    Expression _exp;
    final int _start;
    final TypeNode _typeCast;
    _start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
    st.gravel.support.jvm.ReadStreamExtensions.next(_stream);
    this.eatWhitespace();
    _typeCast = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '{') ? this.parseTypeExpressionAndClose() : null;
    _exp = this.parseAssignmentOrExpression();
    if (_typeCast != null) {
        _exp = TypeCast.factory.type_expression_(_typeCast, _exp);
    }
    this.eatWhitespace();
    st.gravel.support.jvm.ObjectExtensions.assert_(this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ')'));
    return ((Expression) this.setSourcePosition_node_(_start, _exp));
}
Also used : Expression(st.gravel.support.compiler.ast.Expression) BlockTypeNode(st.gravel.support.compiler.ast.BlockTypeNode) SelfTypeNode(st.gravel.support.compiler.ast.SelfTypeNode) InstanceTypeNode(st.gravel.support.compiler.ast.InstanceTypeNode) TypeNode(st.gravel.support.compiler.ast.TypeNode)

Example 14 with Expression

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

the class Parser method parseKeywordMessageChain_receiver_.

public Expression parseKeywordMessageChain_receiver_(final String _aString, final Expression _receiver) {
    String _res;
    final StringBuilder _str;
    final List<Expression> _arguments;
    _str = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    _str.append(_aString);
    _str.append(':');
    _arguments = new java.util.ArrayList();
    this.eatWhitespace();
    _arguments.add(this.parseBinaryOrUnaryMessage());
    this.eatWhitespace();
    _res = this.parseIdentifier();
    boolean _temp1 = false;
    while (!_temp1) {
        _temp1 = _res == null;
        if (!_temp1) {
            st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':'));
            _str.append(_res);
            _str.append(':');
            Parser.this.eatWhitespace();
            _arguments.add(Parser.this.parseBinaryOrUnaryMessage());
            Parser.this.eatWhitespace();
            _res = Parser.this.parseIdentifier();
        }
    }
    return KeywordMessageNode.factory.receiver_selector_arguments_(_receiver, _str.toString(), _arguments.toArray(new Expression[_arguments.size()]));
}
Also used : Expression(st.gravel.support.compiler.ast.Expression) ArrayList(java.util.ArrayList)

Example 15 with Expression

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

the class Parser method parseBinaryMessageChain_receiver_.

public Expression parseBinaryMessageChain_receiver_(final String _aString, final Expression _rec) {
    final Expression _arg;
    final BinaryMessageNode _receiver;
    this.eatWhitespace();
    _arg = this.parseUnaryMessage();
    this.eatWhitespace();
    _receiver = BinaryMessageNode.factory.receiver_selector_argument_(_rec, _aString, _arg);
    return this.parseBinaryOrUnaryMessage_(_receiver);
}
Also used : BinaryMessageNode(st.gravel.support.compiler.ast.BinaryMessageNode) Expression(st.gravel.support.compiler.ast.Expression)

Aggregations

Expression (st.gravel.support.compiler.ast.Expression)25 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)7 BlockNode (st.gravel.support.compiler.ast.BlockNode)6 ArrayList (java.util.ArrayList)3 BinaryMessageNode (st.gravel.support.compiler.ast.BinaryMessageNode)3 MessageNode (st.gravel.support.compiler.ast.MessageNode)3 Statement (st.gravel.support.compiler.ast.Statement)3 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)3 ArrayLiteralNode (st.gravel.support.compiler.ast.ArrayLiteralNode)2 StringLiteralNode (st.gravel.support.compiler.ast.StringLiteralNode)2 List (java.util.List)1 ArrayAtNode (st.gravel.support.compiler.ast.ArrayAtNode)1 ArrayAtPutNode (st.gravel.support.compiler.ast.ArrayAtPutNode)1 ArraySizeNode (st.gravel.support.compiler.ast.ArraySizeNode)1 BlockTypeNode (st.gravel.support.compiler.ast.BlockTypeNode)1 BooleanAndNode (st.gravel.support.compiler.ast.BooleanAndNode)1 BooleanLiteralNode (st.gravel.support.compiler.ast.BooleanLiteralNode)1 BooleanOrNode (st.gravel.support.compiler.ast.BooleanOrNode)1 ByteArrayLiteralNode (st.gravel.support.compiler.ast.ByteArrayLiteralNode)1 CascadeNode (st.gravel.support.compiler.ast.CascadeNode)1