All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.waxeye.parser.ParseResult Maven / Gradle / Ivy

The newest version!
/*
 * Waxeye Parser Generator
 * www.waxeye.org
 * Copyright (C) 2008-2010 Orlando Hill
 * Licensed under the MIT license. See 'LICENSE' for details.
 */
package org.waxeye.parser;

import org.waxeye.ast.IAST;

/**
 * The result of a parse.
 *
 * @param  The AST type.
 *
 * @author Orlando Hill
 */
public final class ParseResult >
{
    /** The AST of a successful parse. */
    private final IAST ast;

    /** The error of an unsuccessful parse. */
    private final ParseError error;

    /**
     * Creates a new ParseResult.
     *
     * @param ast The AST of a successful parse.
     *
     * @param error The error of an unsuccessful parse.
     */
    public ParseResult(final IAST ast, final ParseError error)
    {
        this.ast = ast;
        this.error = error;
    }

    /**
     * Returns the ast.
     *
     * @return Returns the ast.
     */
    public IAST getAST()
    {
        return ast;
    }

    /**
     * Returns the error.
     *
     * @return Returns the error.
     */
    public ParseError getError()
    {
        return error;
    }

    /** {@inheritDoc} */
    public String toString()
    {
        if (ast != null)
        {
            return ast.toString();
        }

        if (error != null)
        {
            return error.toString();
        }

        return "ParseResult(null, null)";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy