use of st.gravel.support.compiler.ast.ArrayLiteralNode in project gravel by gravel-st.
the class ParserTest method testParseLiteralArray.
@Test
public void testParseLiteralArray() {
final ArrayLiteralNode _node;
_node = ((ArrayLiteralNode) Parser.factory.source_("#(#foo foo \'foo\' 1 (a b c) #( a b c) ((x)) () #[1 2 3])").parseExpression());
assertTrue(st.gravel.support.jvm.ObjectExtensions.equals_(_node.factory(), ArrayLiteralNode.factory));
assertEquals((String) "#(#foo #foo \'foo\' 1 #(#a #b #c) #(#a #b #c) #(#(#x)) #() #[1 2 3])", (String) _node.prettySourceString());
assertTrue(st.gravel.support.jvm.IntegerExtensions.equals_(_node.value().length, 9));
}
use of st.gravel.support.compiler.ast.ArrayLiteralNode in project gravel by gravel-st.
the class SourcePrinter method visitArrayLiteralNode_.
@Override
public SourcePrinter visitArrayLiteralNode_(final ArrayLiteralNode _anObject) {
_stream.append("#(");
boolean _temp1 = true;
for (final LiteralNode _each : _anObject.elements()) {
if (_temp1) {
_temp1 = false;
} else {
_stream.append(' ');
}
SourcePrinter.this.visit_(_each);
}
_stream.append(')');
return this;
}
use of st.gravel.support.compiler.ast.ArrayLiteralNode 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.ArrayLiteralNode in project gravel by gravel-st.
the class ParserTest method testParseNilInArray1.
@Test
public void testParseNilInArray1() {
final ArrayLiteralNode _node;
_node = ((ArrayLiteralNode) Parser.factory.source_("#(nil)").parseExpression());
assertEquals((st.gravel.support.jvm.SmalltalkFactory) ArrayLiteralNode.factory, (st.gravel.support.jvm.SmalltalkFactory) _node.factory());
assertEquals((Object) null, (Object) _node.value()[0]);
}
Aggregations