use of st.gravel.support.compiler.ast.PragmaNode in project gravel by gravel-st.
the class SourcePrinter method printPragmas_.
public SourcePrinter printPragmas_(final PragmaNode[] _pragmas) {
for (final PragmaNode _each : _pragmas) {
SourcePrinter.this.crtab_(_indentation);
SourcePrinter.this.visit_(_each);
}
return this;
}
use of st.gravel.support.compiler.ast.PragmaNode in project gravel by gravel-st.
the class MethodNode method primitiveIn_.
public String[] primitiveIn_(final String _className) {
final PragmaNode _pragma;
final Expression _argument;
final ArrayLiteralNode _arrayNode;
_pragma = this.primitivePragma();
if (_pragma == null) {
return null;
}
_argument = _pragma.expression().argument();
if (_argument.isStringLiteralNode()) {
return MethodNode.this.localPrimitiveIn_nameNode_(_className, ((StringLiteralNode) _argument));
}
if (!_argument.isArrayLiteralNode()) {
return null;
}
_arrayNode = ((ArrayLiteralNode) _argument);
return st.gravel.support.jvm.ArrayExtensions.collect_(_arrayNode.value(), ((st.gravel.support.jvm.Block1<String, Object>) (new st.gravel.support.jvm.Block1<String, Object>() {
@Override
public String value_(final Object _e) {
final String _str;
_str = ((String) _e);
return (String) _str;
}
})));
}
use of st.gravel.support.compiler.ast.PragmaNode in project gravel by gravel-st.
the class MethodNode method pragmaPropertyAt_ifAbsent_.
public Object pragmaPropertyAt_ifAbsent_(final st.gravel.core.Symbol _aKey, final st.gravel.support.jvm.Block0<Object> _aBlock) {
final Object _temp1 = new Object();
try {
final PragmaNode _pr;
_pr = ((PragmaNode) st.gravel.support.jvm.ArrayExtensions.detect_ifNone_(_pragmas, new st.gravel.support.jvm.Predicate1<PragmaNode>() {
@Override
public boolean value_(final PragmaNode _each) {
return _each.isPropertyPragmaAt_(_aKey);
}
}, ((st.gravel.support.jvm.Block0<PragmaNode>) (new st.gravel.support.jvm.Block0<PragmaNode>() {
@Override
public PragmaNode value() {
throw new NonLocalReturn(_aBlock.value(), _temp1);
}
}))));
return ((LiteralNode) _pr.expression().arguments()[1]).value();
} catch (NonLocalReturn nlr) {
if (nlr.marker == _temp1) {
return (Object) nlr.returnValue;
} else {
throw nlr;
}
}
}
use of st.gravel.support.compiler.ast.PragmaNode 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)));
}
use of st.gravel.support.compiler.ast.PragmaNode in project gravel by gravel-st.
the class UnaryMethodNode method returnTypeAndBodySourceOn_.
@Override
public UnaryMethodNode returnTypeAndBodySourceOn_(final StringBuilder _aStream) {
if (_returnType != null) {
_aStream.append(' ');
_aStream.append("{^");
_returnType.sourceOn_(_aStream);
_aStream.append('}');
}
for (final PragmaNode _each : _pragmas) {
_aStream.append('\n');
_aStream.append(' ');
_each.sourceOn_(_aStream);
}
_body.methodSourceOn_(_aStream);
return this;
}
Aggregations