Package com.pogofish.jadt.parser

Examples of com.pogofish.jadt.parser.Parser


    /**
     * Test the whole shebang with a minimal document
     */
    @Test
    public void testMinimal() {
        final Parser parser = new StandardParser(PARSER_IMPL_FACTORY);
        final ParseResult result = parser.parse(new StringSource("ParserTest",
                "Foo = Foo"));

        assertEquals(new ParseResult(new Doc("ParserTest", EMPTY_PKG, NO_IMPORTS, list(_DataType(NO_COMMENTS, NO_ANNOTATIONS, "Foo", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                list(_Constructor(NO_COMMENTS, "Foo", Util.<Arg> list()))))), Util.<SyntaxError>list()), result);
    }
View Full Code Here


    /**
     * Test the whole shebang with a less minimal document
     */
    @Test
    public void testFull() {
        final Parser parser = new StandardParser(PARSER_IMPL_FACTORY);
        final String source = "//a pre-start comment\n//a start comment\npackage hello.world /* here are some imports */import wow.man import flim.flam "
                + "//an annotation comment\n@foo\n@foo(@bar)\n//datatype comment\nFooBar //equal comment\n= //constructor comment\nfoo //bar comment\n| //really a bar comment\nbar(int hey, final String[] yeah) whatever = whatever";
        final ParseResult result = parser.parse(new StringSource("ParserTest",
                source));

        assertEquals(
                new ParseResult(new Doc(
                        "ParserTest",
View Full Code Here

    /**
     * Test the whole shebang with an error
     */
    @Test
   public void testError() {
        final Parser parser = new StandardParser(PARSER_IMPL_FACTORY);
        final String source = "//a start comment\npackage hello.world /* here are some imports */import wow.man import flim.flam "
                + "FooBar = foo | bar(int hey, final String[] yeah) whatever = int";
        final ParseResult result = parser.parse(new StringSource("ParserTest",
                source));

        assertEquals(
                new ParseResult(new Doc(
                        "ParserTest",
View Full Code Here

   
   
    @Test
    public void testNonsense() throws Exception {
        // the old parser would get stuck in a loop with this extraneous >
        final Parser parser = new StandardParser(PARSER_IMPL_FACTORY);
       
        final ParseResult result = parser.parse(new StringSource("whatever", "FormalParameter = FormalParameter(final List<Modifier> modifiers>, final TypeRef type, final String name)"));
        assertEquals(ParseResult._ParseResult(Doc._Doc("whatever", EMPTY_PKG, NO_IMPORTS,
                list(_DataType(NO_COMMENTS, NO_ANNOTATIONS, "FormalParameter", NO_FORMAL_TYPE_ARGUMENTS, NO_EXTENDS, NO_IMPLEMENTS,
                        list(_Constructor(NO_COMMENTS, "FormalParameter",
                                list(_Arg(list(_Final()), _Ref(_ClassType("List", list(_ClassType("Modifier", NO_ACTUAL_TYPE_ARGUMENTS)))), "modifiers") /*,
                                     _Arg(list(_Final()), _Ref(_ClassType("TypeRef", Util.<RefType>list())), "type"),
View Full Code Here

        final SourceFactory sourceFactory = new FileSourceFactory();
        final ClassBodyEmitter classBodyEmitter = new StandardClassBodyEmitter();
        final ConstructorEmitter constructorEmitter = new StandardConstructorEmitter(classBodyEmitter);
        final DataTypeEmitter dataTypeEmitter = new StandardDataTypeEmitter(classBodyEmitter, constructorEmitter);
        final DocEmitter docEmitter = new StandardDocEmitter(dataTypeEmitter);     
        final Parser parser = new StandardParser(new JavaCCParserImplFactory());
        final Checker checker = new StandardChecker();
        final SinkFactoryFactory factoryFactory = new FileSinkFactoryFactory();
       
        return new JADT(sourceFactory, parser, checker, docEmitter, factoryFactory);
    }
View Full Code Here

    public static JADT createDummyJADT(List<SyntaxError> syntaxErrors, List<SemanticError> semanticErrors, String testSrcInfo, SinkFactoryFactory factory) {
        final SourceFactory sourceFactory = new StringSourceFactory(TEST_STRING);
        final Doc doc = new Doc(TEST_SRC_INFO, Pkg._Pkg(NO_COMMENTS, "pkg"), Util.<Imprt> list(), Util.<DataType> list());
        final ParseResult parseResult = new ParseResult(doc, syntaxErrors);
        final DocEmitter docEmitter = new DummyDocEmitter(doc,  TEST_CLASS_NAME);
        final Parser parser = new DummyParser(parseResult, testSrcInfo, TEST_STRING);
        final Checker checker = new DummyChecker(semanticErrors);
        final JADT jadt = new JADT(sourceFactory, parser, checker, docEmitter, factory);
        return jadt;
    }   
View Full Code Here

TOP

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

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.