Search in sources :

Example 11 with TypeNode

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

the class Parser method parseBinaryMethod_.

public BinaryMethodNode parseBinaryMethod_(final String _aString) {
    final VariableDeclarationNode _argument;
    final SequenceNode _body;
    final TypeNode _returnType;
    final PragmaNode[][] _pragmas;
    _pragmas = new PragmaNode[1][];
    this.eatWhitespace();
    _argument = this.parseVariableDeclaration();
    _returnType = this.parseReturnType();
    _pragmas[0] = this.readPragmas();
    _body = this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            return _pragmas[0] = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_pragmas[0], _extraPragmas);
        }
    });
    return BinaryMethodNode.factory.selector_argument_body_returnType_pragmas_protocol_(_aString, _argument, _body, _returnType, _pragmas[0], null);
}
Also used : TypeCast(st.gravel.support.compiler.ast.TypeCast) ArrayList(java.util.ArrayList) List(java.util.List) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) 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) SequenceNode(st.gravel.support.compiler.ast.SequenceNode)

Example 12 with TypeNode

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

the class Parser method parseUnaryMethod_.

public MethodNode parseUnaryMethod_(final String _aString) {
    final SequenceNode _body;
    final TypeNode _returnType;
    final PragmaNode[][] _pragmas;
    _pragmas = new PragmaNode[1][];
    _returnType = this.parseReturnType();
    _pragmas[0] = this.readPragmas();
    _body = this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            return _pragmas[0] = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_pragmas[0], _extraPragmas);
        }
    });
    return UnaryMethodNode.factory.selector_body_returnType_pragmas_protocol_(_aString, _body, _returnType, _pragmas[0], null);
}
Also used : TypeCast(st.gravel.support.compiler.ast.TypeCast) ArrayList(java.util.ArrayList) List(java.util.List) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) 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) SequenceNode(st.gravel.support.compiler.ast.SequenceNode)

Example 13 with TypeNode

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

the class Parser method parseTypeNode.

public TypeNode parseTypeNode() {
    TypeNode _exp;
    _exp = this.parseTypeOperand();
    this.eatWhitespace();
    boolean _temp1 = true;
    while (_temp1) {
        _temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|');
        if (_temp1) {
            _exp = _exp.$pipe$(Parser.this.parseTypeOperand());
            Parser.this.eatWhitespace();
        }
    }
    return _exp;
}
Also used : 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 TypeNode

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

the class Parser method parseBlock.

public BlockNode parseBlock() {
    VariableDeclarationNode[] _arguments;
    final BlockNode _bn;
    TypeNode _returnType;
    final int _start;
    _start = st.gravel.support.jvm.ReadStreamExtensions.position(_stream);
    st.gravel.support.jvm.ReadStreamExtensions.next(_stream);
    this.eatWhitespace();
    _arguments = new VariableDeclarationNode[] {};
    if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':')) {
        boolean _temp1 = true;
        while (_temp1) {
            Parser.this.eatWhitespace();
            _arguments = st.gravel.support.jvm.ArrayExtensions.copyWith_(_arguments, Parser.this.parseVariableDeclaration());
            Parser.this.eatWhitespace();
            _temp1 = st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ':');
        }
        _returnType = Parser.this.parseReturnType();
        Parser.this.eatWhitespace();
        if (st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ']')) {
            return BlockNode.factory.arguments_body_returnType_(_arguments, SequenceNode.factory.empty(), _returnType);
        }
        st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|'));
    } else {
        _returnType = Parser.this.parseReturnType();
        if (_returnType != null) {
            Parser.this.eatWhitespace();
            st.gravel.support.jvm.ObjectExtensions.assert_(Parser.this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, '|'));
        }
    }
    _bn = BlockNode.factory.arguments_body_returnType_(_arguments, this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            throw new RuntimeException("Extra pragmas not allowed");
        }
    }), _returnType);
    st.gravel.support.jvm.ObjectExtensions.assert_(this, st.gravel.support.jvm.ReadStreamExtensions.peekFor_(_stream, ']'));
    return ((BlockNode) this.setSourcePosition_node_(_start, _bn));
}
Also used : BlockNode(st.gravel.support.compiler.ast.BlockNode) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) 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 15 with TypeNode

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

the class Parser method parseKeywordMethod_.

public KeywordMethodNode parseKeywordMethod_(final String _aString) {
    String _res;
    final StringBuilder _str;
    final List<VariableDeclarationNode> _arguments;
    final SequenceNode _body;
    final TypeNode _returnType;
    final PragmaNode[][] _pragmas;
    _pragmas = new PragmaNode[1][];
    _str = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    _str.append(_aString);
    _str.append(':');
    _arguments = new java.util.ArrayList();
    this.eatWhitespace();
    _arguments.add(this.parseVariableDeclaration());
    this.eatWhitespace();
    _res = this.parseKeywordIdentifier();
    boolean _temp1 = false;
    while (!_temp1) {
        _temp1 = _res == null;
        if (!_temp1) {
            _str.append(_res);
            Parser.this.eatWhitespace();
            _arguments.add(Parser.this.parseVariableDeclaration());
            Parser.this.eatWhitespace();
            _res = Parser.this.parseKeywordIdentifier();
        }
    }
    _returnType = this.parseReturnType();
    _pragmas[0] = this.readPragmas();
    _body = this.parseSequenceNode_(new st.gravel.support.jvm.Block1<Object, PragmaNode[]>() {

        @Override
        public Object value_(final PragmaNode[] _extraPragmas) {
            return _pragmas[0] = st.gravel.support.jvm.ArrayExtensions.copyWithAll_(_pragmas[0], _extraPragmas);
        }
    });
    return KeywordMethodNode.factory.selector_arguments_body_returnType_pragmas_protocol_(_str.toString(), _arguments.toArray(new VariableDeclarationNode[_arguments.size()]), _body, _returnType, _pragmas[0], null);
}
Also used : TypeCast(st.gravel.support.compiler.ast.TypeCast) ArrayList(java.util.ArrayList) List(java.util.List) PragmaNode(st.gravel.support.compiler.ast.PragmaNode) SequenceNode(st.gravel.support.compiler.ast.SequenceNode) ArrayList(java.util.ArrayList) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) 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)

Aggregations

TypeNode (st.gravel.support.compiler.ast.TypeNode)15 BlockTypeNode (st.gravel.support.compiler.ast.BlockTypeNode)12 InstanceTypeNode (st.gravel.support.compiler.ast.InstanceTypeNode)12 SelfTypeNode (st.gravel.support.compiler.ast.SelfTypeNode)12 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)4 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)4 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)3 TypeCast (st.gravel.support.compiler.ast.TypeCast)3 BottomTypeNode (st.gravel.support.compiler.ast.BottomTypeNode)2 ClassTypeNode (st.gravel.support.compiler.ast.ClassTypeNode)2 BlockNode (st.gravel.support.compiler.ast.BlockNode)1 Expression (st.gravel.support.compiler.ast.Expression)1 Statement (st.gravel.support.compiler.ast.Statement)1