Search in sources :

Example 1 with Statement

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

the class ParserTest method testParseKeywordExpression.

@Test
public void testParseKeywordExpression() {
    final Statement _node;
    _node = Parser.factory.source_(" 3 foo: 7 bar: 4 ").parseExpression();
    assertEquals((st.gravel.support.jvm.SmalltalkFactory) KeywordMessageNode.factory, (st.gravel.support.jvm.SmalltalkFactory) _node.factory());
    assertEquals((String) "3 foo: 7 bar: 4", (String) _node.prettySourceString());
}
Also used : Statement(st.gravel.support.compiler.ast.Statement) Test(org.junit.Test)

Example 2 with Statement

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

the class ParserTest method testParse2ArgBlockEmpty2.

@Test
public void testParse2ArgBlockEmpty2() {
    final Statement _node;
    _node = Parser.factory.source_("[:a :b ]").parseExpression();
    assertTrue(st.gravel.support.jvm.ObjectExtensions.equals_(_node.factory(), BlockNode.factory));
    assertEquals((String) "[:a :b | ]", (String) _node.prettySourceString());
}
Also used : Statement(st.gravel.support.compiler.ast.Statement) Test(org.junit.Test)

Example 3 with Statement

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

the class ParserTest method testParseCascade.

@Test
public void testParseCascade() {
    final Statement _node;
    _node = Parser.factory.source_("3 foo + 2\n\t\t+ 3;\n\t\tbar: 2;\n\t\tbaz: 3;\n\t\tbaz: 4;\n\t\tboo").parseExpression();
    assertEquals((st.gravel.support.jvm.SmalltalkFactory) CascadeNode.factory, (st.gravel.support.jvm.SmalltalkFactory) _node.factory());
    assertEquals((String) "(3 foo + 2) + 3; bar: 2; baz: 3; baz: 4; boo", (String) _node.prettySourceString());
}
Also used : Statement(st.gravel.support.compiler.ast.Statement) Test(org.junit.Test)

Example 4 with Statement

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

the class ParserTest method testParseKeywordBinaryUnaryExpression3.

@Test
public void testParseKeywordBinaryUnaryExpression3() {
    final Statement _node;
    _node = Parser.factory.source_("2 + 7 foo: 7 bar: 4 baz foo: 2 + 1 boo: 3 foo + 2 roo: 3 + 2 foo noo: 3 hoo + 2 joo").parseExpression();
    assertTrue(st.gravel.support.jvm.ObjectExtensions.equals_(_node.factory(), KeywordMessageNode.factory));
    assertEquals((String) "2 + 7\n\tfoo: 7\n\tbar: 4 baz\n\tfoo: 2 + 1\n\tboo: 3 foo + 2\n\troo: 3 + 2 foo\n\tnoo: 3 hoo + 2 joo", (String) _node.prettySourceString());
}
Also used : Statement(st.gravel.support.compiler.ast.Statement) Test(org.junit.Test)

Example 5 with Statement

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

the class ParserTest method testAssignmentExpression.

@Test
public void testAssignmentExpression() {
    final Statement _node;
    _node = Parser.factory.source_(" foo := 7 ").parseStatement();
    assertTrue(st.gravel.support.jvm.ObjectExtensions.equals_(_node.factory(), AssignmentNode.factory));
    assertEquals((String) "foo := 7", (String) _node.prettySourceString());
}
Also used : Statement(st.gravel.support.compiler.ast.Statement) Test(org.junit.Test)

Aggregations

Statement (st.gravel.support.compiler.ast.Statement)34 Test (org.junit.Test)21 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)5 BinaryMessageNode (st.gravel.support.compiler.ast.BinaryMessageNode)3 Expression (st.gravel.support.compiler.ast.Expression)3 KeywordMessageNode (st.gravel.support.compiler.ast.KeywordMessageNode)3 MessageNode (st.gravel.support.compiler.ast.MessageNode)3 UnaryMessageNode (st.gravel.support.compiler.ast.UnaryMessageNode)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IntermediateStatement (st.gravel.support.compiler.ast.IntermediateStatement)1 PragmaNode (st.gravel.support.compiler.ast.PragmaNode)1 TypeNode (st.gravel.support.compiler.ast.TypeNode)1 VariableNode (st.gravel.support.compiler.ast.VariableNode)1 VariableScopeAnalyzerState (st.gravel.support.compiler.ast.VariableScopeAnalyzerState)1