Package mireka.address.parser.ast

Examples of mireka.address.parser.ast.PathAST


    public PathParser(CharScanner charScanner) {
        super(charScanner);
    }

    public PathAST parse() throws ParseException {
        PathAST pathAST = parsePath();
        if (currentToken.ch != -1)
            throw currentToken.otherSyntaxException("Superfluous characters "
                    + "after path: {0}.");
        return pathAST;
    }
View Full Code Here


                    + "after path: {0}.");
        return pathAST;
    }

    public PathAST parseLeft() throws ParseException {
        PathAST pathAST = parsePath();
        scanner.pushBack(currentToken);
        return pathAST;
    }
View Full Code Here

            sourceRouteAST = parseSourceRoute();
            accept(':');
        }
        MailboxAST mailboxAST = parseMailbox();
        accept('>');
        return new PathAST(popPosition(), sourceRouteAST, mailboxAST);
    }
View Full Code Here

import org.junit.Test;

public class PathParserTest {
    @Test
    public void testSimplePath() throws Exception {
        PathAST pathAST = new PathParser("<john@example.com>").parse();
        assertNull(pathAST.sourceRouteAST);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
        assertEquals("example.com", pathAST.mailboxAST.remotePartAST.spelling);
    }
View Full Code Here

        assertEquals("example.com", pathAST.mailboxAST.remotePartAST.spelling);
    }

    @Test
    public void testSourceRoute1() throws Exception {
        PathAST pathAST = new PathParser("<@example.org:john@example.com>").parse();
        assertEquals(1, pathAST.sourceRouteAST.domainASTs.size());
        assertEquals("example.org", pathAST.sourceRouteAST.domainASTs.get(0).spelling);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
    }
View Full Code Here

        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
    }

    @Test
    public void testSourceRoute2() throws Exception {
        PathAST pathAST =
                new PathParser("<@example.org@example.net:john@example.com>")
                        .parse();
        assertEquals(2, pathAST.sourceRouteAST.domainASTs.size());
        assertEquals("example.org", pathAST.sourceRouteAST.domainASTs.get(0).spelling);
        assertEquals("john", pathAST.mailboxAST.localPartAST.spelling);
View Full Code Here

        if (inputEquals("<>")) {
            accept('<');
            accept('>');
            return new NullReversePathAST(popPosition());
        } else {
            PathAST pathAST = parsePath();
            return new RealReversePathAST(popPosition(), pathAST);
        }
    }
View Full Code Here

        return peekString(s.length()).equals(s);
    }

    private PathAST parsePath() throws ParseException {
        scanner.pushBack(currentToken);
        PathAST pathAST = new PathParser(scanner).parseLeft();
        currentToken = scanner.scan();
        return pathAST;
    }
View Full Code Here

    private RecipientAST parseRecipient() throws ParseException {
        String DOMAIN_POSTMASTER_PREFIX = "<Postmaster@";
        String SYSTEM_POSTMASTER_PREFIX = "<Postmaster>";
        pushPosition();
        if (inputEqualsIgnoreCase(DOMAIN_POSTMASTER_PREFIX)) {
            PathAST pathAST = parsePath();
            if (pathAST.mailboxAST.remotePartAST instanceof DomainRemotePartAST)
                return new DomainPostmasterRecipientAST(popPosition(),
                        pathAST.mailboxAST);
            else
                return new MailboxRecipientAST(popPosition(), pathAST);
        } else if (inputEqualsIgnoreCase(SYSTEM_POSTMASTER_PREFIX)) {
            accept('<');
            pushSpelling();
            acceptThem(SYSTEM_POSTMASTER_PREFIX.length() - 2);
            String postmasterSpelling = popSpelling();
            accept('>');
            return new SystemPostmasterRecipientAST(popPosition(), postmasterSpelling);
        } else {
            PathAST pathAST = parsePath();
            return new MailboxRecipientAST(popPosition(), pathAST);
        }
    }
View Full Code Here

                sLowerCase);
    }

    private PathAST parsePath() throws ParseException {
        scanner.pushBack(currentToken);
        PathAST pathAST = new PathParser(scanner).parseLeft();
        currentToken = scanner.scan();
        return pathAST;
    }
View Full Code Here

TOP

Related Classes of mireka.address.parser.ast.PathAST

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.