Search in sources :

Example 1 with ArrayLiteralNode

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));
}
Also used : ByteArrayLiteralNode(st.gravel.support.compiler.ast.ByteArrayLiteralNode) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) Test(org.junit.Test)

Example 2 with ArrayLiteralNode

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;
}
Also used : CharacterLiteralNode(st.gravel.support.compiler.ast.CharacterLiteralNode) NilLiteralNode(st.gravel.support.compiler.ast.NilLiteralNode) LiteralNode(st.gravel.support.compiler.ast.LiteralNode) ReferenceLiteralNode(st.gravel.support.compiler.ast.ReferenceLiteralNode) SymbolLiteralNode(st.gravel.support.compiler.ast.SymbolLiteralNode) ByteArrayLiteralNode(st.gravel.support.compiler.ast.ByteArrayLiteralNode) IntegerLiteralNode(st.gravel.support.compiler.ast.IntegerLiteralNode) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) FloatLiteralNode(st.gravel.support.compiler.ast.FloatLiteralNode) BooleanLiteralNode(st.gravel.support.compiler.ast.BooleanLiteralNode) DoubleLiteralNode(st.gravel.support.compiler.ast.DoubleLiteralNode) StringLiteralNode(st.gravel.support.compiler.ast.StringLiteralNode) FixedPointLiteralNode(st.gravel.support.compiler.ast.FixedPointLiteralNode)

Example 3 with ArrayLiteralNode

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;
        }
    })));
}
Also used : PragmaNode(st.gravel.support.compiler.ast.PragmaNode) Expression(st.gravel.support.compiler.ast.Expression) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) StringLiteralNode(st.gravel.support.compiler.ast.StringLiteralNode)

Example 4 with ArrayLiteralNode

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]);
}
Also used : ByteArrayLiteralNode(st.gravel.support.compiler.ast.ByteArrayLiteralNode) ArrayLiteralNode(st.gravel.support.compiler.ast.ArrayLiteralNode) Test(org.junit.Test)

Aggregations

ArrayLiteralNode (st.gravel.support.compiler.ast.ArrayLiteralNode)4 ByteArrayLiteralNode (st.gravel.support.compiler.ast.ByteArrayLiteralNode)3 Test (org.junit.Test)2 StringLiteralNode (st.gravel.support.compiler.ast.StringLiteralNode)2 BooleanLiteralNode (st.gravel.support.compiler.ast.BooleanLiteralNode)1 CharacterLiteralNode (st.gravel.support.compiler.ast.CharacterLiteralNode)1 DoubleLiteralNode (st.gravel.support.compiler.ast.DoubleLiteralNode)1 Expression (st.gravel.support.compiler.ast.Expression)1 FixedPointLiteralNode (st.gravel.support.compiler.ast.FixedPointLiteralNode)1 FloatLiteralNode (st.gravel.support.compiler.ast.FloatLiteralNode)1 IntegerLiteralNode (st.gravel.support.compiler.ast.IntegerLiteralNode)1 LiteralNode (st.gravel.support.compiler.ast.LiteralNode)1 NilLiteralNode (st.gravel.support.compiler.ast.NilLiteralNode)1 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)1 ReferenceLiteralNode (st.gravel.support.compiler.ast.ReferenceLiteralNode)1 SymbolLiteralNode (st.gravel.support.compiler.ast.SymbolLiteralNode)1