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);
}
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);
}
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;
}
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));
}
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);
}
Aggregations