Package com.google.minijoe.compiler.ast

Examples of com.google.minijoe.compiler.ast.FunctionLiteral


      statementVector.addElement(parseSourceElement());
    }

    readToken(Token.OPERATOR_CLOSEBRACE);

    return new FunctionLiteral(name,
        Util.vectorToIdentifierArray(parameterVector),
        Util.vectorToStatementArray(statementVector)
    );
  }
View Full Code Here


  }

  public void testFunctionDeclaration() throws CompilerException {
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "function foo() {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a) {}"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                  new Identifier("b"),
                  new Identifier("c"),
                },
                new Statement[] {
                }
            )
        ),
        "function foo(a, b, c) {};"
    );
    assertParserOutput(
        new FunctionDeclaration(
            new FunctionLiteral(
                new Identifier("a"),
                new Identifier[] {
                },
                new Statement[] {
                  new FunctionDeclaration(
                      new FunctionLiteral(
                          new Identifier("b"),
                          new Identifier[] {
                          },
                          new Statement[] {
                            new IfStatement(
                                new NumberLiteral(0.0),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        new Identifier("c"),
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
                                    )
                                ),
                                new ExpressionStatement(
                                    new FunctionLiteral(
                                        null,
                                        new Identifier[] {
                                        },
                                        new Statement[] {
                                        }
View Full Code Here

    // we're need to put the function literals in parenthesis to ensure that
    // they're parsed as function expressions and not function declarations.

    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                null,
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function () {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                },
                new Statement[] {
                }
            )
        ),
        "(function foo() {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                },
                new Statement[] {
                }
            )
        ),
        "(function foo(a) {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                  new Identifier("a"),
                  new Identifier("b"),
                  new Identifier("c"),
                },
                new Statement[] {
                }
            )
        ),
        "(function foo(a, b, c) {});"
    );
    assertParserOutput(
        new ExpressionStatement(
            new FunctionLiteral(
                new Identifier("foo"),
                new Identifier[] {
                    new Identifier("a"),
                    new Identifier("b"),
                    new Identifier("c"),
View Full Code Here

TOP

Related Classes of com.google.minijoe.compiler.ast.FunctionLiteral

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.