Package com.pogofish.jadt.parser

Examples of com.pogofish.jadt.parser.ParserImpl


    /**
     * Test unterminated comments
     */
    @Test
    public void testUnterminatedComment() throws Exception {
        final ParserImpl p1 = parserImpl("/** hello");
        checkError(list(_UnexpectedToken("whatever", "unterminated comment", 1)), "BAD_IDENTIFIER_unterminated comment@1", p1.identifier("whatever"), p1);

    }
View Full Code Here


                parserImpl("Foo[]").refType());
    }
   
    @Test
    public void testRefTypeErrors() throws Exception {
        final ParserImpl p1 = parserImpl("Foo[");
        checkError(list(_UnexpectedToken("']'", "<EOF>", 1)), _ArrayType(_Ref(_ClassType("Foo", NO_ACTUAL_TYPE_ARGUMENTS))), p1.refType(), p1);

        final ParserImpl p2 = parserImpl("Foo<int>");
        checkError(list(_UnexpectedToken("'['", "'>'", 1)), _Ref(_ClassType("Foo", list(_ArrayType(_Primitive(_IntType()))))), p2.type(), p2);

        final ParserImpl p3 = parserImpl("Foo<A");
        checkError(list(_UnexpectedToken("'>'", "<EOF>", 1)), _Ref(_ClassType("Foo", list(_ClassType("A", NO_ACTUAL_TYPE_ARGUMENTS)))), p3.type(), p3);

        final ParserImpl p4 = parserImpl("Foo<A B>");
        checkError(list(_UnexpectedToken("'>'", "'B'", 1)), _Ref(_ClassType("Foo", list(_ClassType("A", NO_ACTUAL_TYPE_ARGUMENTS)))), p4.type(), p4);

        final ParserImpl p5 = parserImpl("");
        checkError(list(_UnexpectedToken("a class name", "<EOF>", 1)), _Ref(_ClassType("NO_IDENTIFIER@1", NO_ACTUAL_TYPE_ARGUMENTS)), p5.type(), p5);
       
        final ParserImpl p6 = parserImpl("import");
        checkError(list(_UnexpectedToken("a class name", "'import'", 1)), _Ref(_ClassType("BAD_IDENTIFIER_import@1", NO_ACTUAL_TYPE_ARGUMENTS)), p6.type(), p6);
       
    }
View Full Code Here

                parserImpl("final int Foo").arg());
    }
   
    @Test
   public void testArgErrors() throws Exception {
        ParserImpl p1 = parserImpl("int");
        checkError(list(_UnexpectedToken("an argument name", "<EOF>", 1)), _Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "NO_IDENTIFIER@1"), p1.arg(), p1);

        ParserImpl p2 = parserImpl("int boolean");
        checkError(list(_UnexpectedToken("an argument name", "'boolean'", 1)), _Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "BAD_IDENTIFIER_boolean@1"), p2.arg(), p2);

    }
View Full Code Here

                parserImpl("(int Foo, boolean Bar)").args());
    }
   
    @Test
   public void testArgsErrors() throws Exception {
        ParserImpl p1 = parserImpl("(int Foo");
        checkError(list(_UnexpectedToken("')'", "<EOF>", 1)), list(_Arg(Util.<ArgModifier>list(), _Primitive(_IntType()), "Foo")), p1.args(), p1);
       
        ParserImpl p2 = parserImpl("()");
        checkError(list(_UnexpectedToken("a class name", "')'", 1)), list(_Arg(Util.<ArgModifier>list(), _Ref(_ClassType("NO_IDENTIFIER@1", NO_ACTUAL_TYPE_ARGUMENTS)), "NO_IDENTIFIER@2")), p2.args(), p2);

        ParserImpl p3 = parserImpl("(int Foo,)");
        checkError(list(_UnexpectedToken("a class name", "')'", 1)), list(_Arg(Util.<ArgModifier> list(), _Primitive(_IntType()),
                "Foo"), _Arg(Util.<ArgModifier>list(), _Ref(_ClassType("NO_IDENTIFIER@1", NO_ACTUAL_TYPE_ARGUMENTS)), "NO_IDENTIFIER@2")), p3.args(), p3);
       
        ParserImpl p4 = parserImpl("(int Foo int Bar)");
        checkError(list(_UnexpectedToken("')'", "'int'", 1)), list(_Arg(Util.<ArgModifier> list(), _Primitive(_IntType()),
                "Foo")), p4.args(), p4);
    }
View Full Code Here

                parserImpl("Foo(int Bar)").constructor(NO_COMMENTS));
    }
   
  @Test
  public void testConstructorErrors() throws Exception {
        ParserImpl p1 = parserImpl("");
        checkError(list(_UnexpectedToken("a constructor name", "<EOF>", 1)), _Constructor(NO_COMMENTS, "NO_IDENTIFIER@1", Util.<Arg>list()), p1.constructor(NO_COMMENTS), p1);
    }
View Full Code Here

                parserImpl("Foo|Bar").constructors(NO_COMMENTS));
    }
   
    @Test
   public void testConstructorsErrors() throws Exception {
        final ParserImpl p1 = parserImpl("Foo|");
        checkError(list(_UnexpectedToken("a constructor name", "<EOF>", 1)),
                list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg>list()), _Constructor(NO_COMMENTS, "NO_IDENTIFIER@1", Util.<Arg>list())), p1.constructors(NO_COMMENTS), p1);
    }
View Full Code Here

    }
   
    @Test
   public void testDataTypeErrors() throws Exception {
       
        final ParserImpl p1 = parserImpl("boolean = Foo");
        checkError(list(_UnexpectedToken("a data type name", "'boolean'", 1)), _DataType(NO_COMMENTS, NO_ANNOTATIONS, "BAD_IDENTIFIER_boolean@1", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS, list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg>list()))), p1.dataType(), p1);
        final ParserImpl p2 = parserImpl("= Foo");
        checkError(list(_UnexpectedToken("a data type name", "'='", 1)), _DataType(NO_COMMENTS, NO_ANNOTATIONS, "NO_IDENTIFIER@1", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS, list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg>list()))), p2.dataType(), p2);
        final ParserImpl p3 = parserImpl("Bar Foo");
        checkError(list(_UnexpectedToken("'='", "'Foo'", 1)), _DataType(NO_COMMENTS, NO_ANNOTATIONS, "Bar", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS, list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg>list()))), p3.dataType(), p3);

        final ParserImpl p4 = parserImpl("");
        checkError(list(_UnexpectedToken("a data type name", "<EOF>", 1)), _DataType(NO_COMMENTS, NO_ANNOTATIONS, "NO_IDENTIFIER@1", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS, list(_Constructor(NO_COMMENTS, "NO_IDENTIFIER@2", Util.<Arg>list()))), p4.dataType(), p4);

        final ParserImpl p5 = parserImpl("Bar<A, = Foo");
        checkError(list(_UnexpectedToken("a type parameter", "'='", 1)), _DataType(NO_COMMENTS, NO_ANNOTATIONS, "Bar", list("A", "NO_IDENTIFIER@1"), NO_EXTENDS, NO_IMPLEMENTS, list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg>list()))), p5.dataType(), p5);
    }
View Full Code Here

    }
   
    @Test
   public void testTypeArgumentsErrors() throws Exception {
       
        ParserImpl p1 = parserImpl("<>");
        checkError(list(_UnexpectedToken("a type parameter", "'>'", 1)), list("NO_IDENTIFIER@1"), p1.typeArguments(), p1);

        ParserImpl p2 = parserImpl("<A");
        checkError(list(_UnexpectedToken("'>'", "<EOF>", 1)), list("A"), p2.typeArguments(), p2);

        ParserImpl p3 = parserImpl("<");
        checkError(list(_UnexpectedToken("a type parameter", "<EOF>", 1)), list("NO_IDENTIFIER@1"), p3.typeArguments(), p3);

        ParserImpl p4 = parserImpl("<boolean, A>");
        checkError(list(_UnexpectedToken("a type parameter", "'boolean'", 1)), list("BAD_IDENTIFIER_boolean@1", "A"), p4.typeArguments(), p4);

        ParserImpl p5 = parserImpl("<A, ,B>");
        checkError(list(_UnexpectedToken("a type parameter", "','", 1)), list("A", "NO_IDENTIFIER@1", "B"), p5.typeArguments(), p5);

        ParserImpl p6 = parserImpl("<A B>");
        checkError(list(_UnexpectedToken("'>'", "'B'", 1)), list("A"), p6.typeArguments(), p6);

    }
View Full Code Here

    }
   
    @Test
    public void testPackageErrors() throws Exception {
       
        final ParserImpl p1 = parserImpl("package");
        checkError(list(_UnexpectedToken("a package name", "<EOF>", 1)), Pkg._Pkg(NO_COMMENTS, "NO_IDENTIFIER@1"), p1.pkg(), p1);

        final ParserImpl p3 = parserImpl("package 42");
        checkError(list(_UnexpectedToken("a package name", "'42'", 1)), Pkg._Pkg(NO_COMMENTS, "BAD_IDENTIFIER_42@1"), p3.pkg(), p3);

        final ParserImpl p4 = parserImpl("package boolean");
        checkError(list(_UnexpectedToken("a package name", "'boolean'", 1)), Pkg._Pkg(NO_COMMENTS, "BAD_IDENTIFIER_boolean@1"), p4.pkg(), p4);
    }
View Full Code Here

                parserImpl("import hello import oh.yeah").imports());
    }
   
    @Test
    public void testImportsErrors() throws Exception {
        final ParserImpl p1 = parserImpl("import");
        checkError(list(_UnexpectedToken("a package name", "<EOF>", 1)), list(Imprt._Imprt(NO_COMMENTS, "NO_IDENTIFIER@1")), p1.imports(), p1);
       
        final ParserImpl p2 = parserImpl("import 42");
        checkError(list(_UnexpectedToken("a package name", "'42'", 1)), list(Imprt._Imprt(NO_COMMENTS, "BAD_IDENTIFIER_42@1")), p2.imports(), p2);
       
        final ParserImpl p3 = parserImpl("import boolean");
        checkError(list(_UnexpectedToken("a package name", "'boolean'", 1)), list(Imprt._Imprt(NO_COMMENTS, "BAD_IDENTIFIER_boolean@1")), p3.imports(), p3);      

        final ParserImpl p4 = parserImpl("import import boolean");
        checkError(list(_UnexpectedToken("a package name", "'import'", 1)), list(Imprt._Imprt(NO_COMMENTS, "BAD_IDENTIFIER_import@1")), p4.imports(), p4);      

        final ParserImpl p5 = parserImpl("import package boolean");
        checkError(list(_UnexpectedToken("a package name", "'package'", 1)), list(Imprt._Imprt(NO_COMMENTS, "BAD_IDENTIFIER_package@1")), p5.imports(), p5);      
    }
View Full Code Here

TOP

Related Classes of com.pogofish.jadt.parser.ParserImpl

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.