Package net.percederberg.grammatica.parser

Examples of net.percederberg.grammatica.parser.ParseException


        if (token != null) {
            node.addValue(token);
        } else if (prod != null) {
            node.addValue(prod);
        } else {
            throw new ParseException(
                ParseException.ANALYSIS_ERROR,
                "unrecognized identifier '" + name + "'",
                node.getStartLine(),
                node.getStartColumn());
        }
View Full Code Here


        str = str.substring(1, str.length() - 1);
        token = grammar.getTokenPatternByImage(str);
        if (token != null) {
            node.addValue(token);
        } else {
            throw new ParseException(
                ParseException.ANALYSIS_ERROR,
                "unrecognized token \"" + str + "\"",
                node.getStartLine(),
                node.getStartColumn());
        }
View Full Code Here

        for (int i = 0; i < child.getValueCount(); i++) {
            alt = (ProductionPatternAlternative) getValue(child, i);
            try {
                pattern.addAlternative(alt);
            } catch (ParserCreationException e) {
                throw new ParseException(
                    ParseException.ANALYSIS_ERROR,
                    e.getMessage(),
                    node.getStartLine(),
                    node.getStartColumn());
            }
View Full Code Here

            for (int i = 0; i < node.getValueCount(); i++) {
                alt = (ProductionPatternAlternative) getValue(node, i);
                try {
                    prod.addAlternative(alt);
                } catch (ParserCreationException e) {
                    throw new ParseException(
                        ParseException.ANALYSIS_ERROR,
                        e.getMessage(),
                        node.getStartLine(),
                        node.getStartColumn());
                }
View Full Code Here

        StringBuffer  buf = new StringBuffer(name.toUpperCase());
        char          c;

        // Check for identifier token
        if (token.getId() != GrammarConstants.IDENTIFIER) {
            throw new ParseException(ParseException.INTERNAL_ERROR,
                                     null,
                                     token.getStartLine(),
                                     token.getStartColumn());
        }

        // Remove all non-identifier characters
        for (int i = 0; i < buf.length(); i++) {
            c = buf.charAt(i);
            if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9')) {
                // Do nothing
            } else {
                buf.deleteCharAt(i--);
            }
        }

        // Check for name collitions
        if (names.containsKey(buf.toString())) {
            throw new ParseException(
                ParseException.ANALYSIS_ERROR,
                "duplicate identifier '" + name + "' is similar or " +
                "equal to previously defined identifier '" +
                names.get(buf.toString()) + "'",
                token.getStartLine(),
View Full Code Here

            parser.parse();
            fail("parsing succeeded");
        } catch (ParserCreationException e) {
            fail(e.getMessage());
        } catch (ParserLogException e) {
            ParseException  p = e.getError(0);

            assertEquals("error count", 1, e.getErrorCount());
            assertEquals("error type", type, p.getErrorType());
            assertEquals("line number", line, p.getLine());
            assertEquals("column number", column, p.getColumn());
        }
    }
View Full Code Here

     *
     * @param file           the file affected
     * @param log            the parser log exception
     */
    void addAll(File file, ParserLogException log) {
        ParseException  e;

        for (int i = 0; i < log.getErrorCount(); i++) {
            e = log.getError(i);
            addError(file, e.getLine(), e.getColumn(), e.getErrorMessage());
        }
    }
View Full Code Here

        MibMacroSymbol  symbol;

        // Check macro name
        name = getStringValue(getChildAt(node, 0), 0);
        if (currentMib.getSymbol(name) != null) {
            throw new ParseException(
                ParseException.ANALYSIS_ERROR,
                "a symbol '" + name + "' already present in the MIB",
                node.getStartLine(),
                node.getStartColumn());
        }
View Full Code Here

        MibTypeSymbol  symbol;

        // Check type name
        name = getStringValue(getChildAt(node, 0), 0);
        if (currentMib.getSymbol(name) != null) {
            throw new ParseException(
                ParseException.ANALYSIS_ERROR,
                "a symbol '" + name + "' already present in the MIB",
                node.getStartLine(),
                node.getStartColumn());
        }
View Full Code Here

            switch (child.getId()) {
            case Asn1Constants.MODULE_REFERENCE:
                name = getStringValue(child, 0);
                local = currentMib.getImport(name);
                if (local == null) {
                    throw new ParseException(
                        ParseException.ANALYSIS_ERROR,
                        "referenced module not imported '" + name + "'",
                        child.getStartLine(),
                        child.getStartColumn());
                }
View Full Code Here

TOP

Related Classes of net.percederberg.grammatica.parser.ParseException

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.