Package org.parboiled.errors

Examples of org.parboiled.errors.GrammarException


                String sb = '"' + String.valueOf(b) + '"';
                String msg = a.length == b.length ? sa + " is specified twice in a FirstOf(String...)" : sa +
                        " is a prefix of " + sb + " in a FirstOf(String...) and comes before " +
                        sb + ", which prevents " + sb +
                        " from ever matching! You should reverse the order of the two alternatives.";
                throw new GrammarException(msg);
            }
        }
    }
View Full Code Here


     * @param errorMessageFormat the error message format
     * @param errorMessageArgs   the error message arguments
     */
    public static void ensure(boolean condition, String errorMessageFormat, Object... errorMessageArgs) {
        if (!condition) {
            throw new GrammarException(errorMessageFormat, errorMessageArgs);
        }
    }
View Full Code Here

     * @param condition    the condition
     * @param errorMessage the error message
     */
    public static void ensure(boolean condition, String errorMessage) {
        if (!condition) {
            throw new GrammarException(errorMessage);
        }
    }
View Full Code Here

        // collect all further matches as well
        int lastIndex = context.getCurrentIndex();
        while (subMatcher.getSubContext(context).runMatcher()) {
            int currentIndex = context.getCurrentIndex();
            if (currentIndex == lastIndex) {
                throw new GrammarException("The inner rule of OneOrMore rule '%s' must not allow empty matches",
                        context.getPath());
            }
            lastIndex = currentIndex;
        }
View Full Code Here

    public boolean match(@NotNull MatcherContext context) {
        int lastIndex = context.getCurrentIndex();
        while (subMatcher.getSubContext(context).runMatcher()) {
            int currentLocation = context.getCurrentIndex();
            if (currentLocation == lastIndex) {
                throw new GrammarException("The inner rule of ZeroOrMore rule '%s' must not allow empty matches",
                        context.getPath());
            }
            lastIndex = currentLocation;
        }
View Full Code Here

    public char getFirstMatchChar() {
        checkActionContext();
        int ix = subContext.startIndex;
        if (subContext.currentIndex <= ix) {
            throw new GrammarException("getFirstMatchChar called but previous rule did not match anything");
        }
        return inputBuffer.charAt(ix);
    }
View Full Code Here

            return new ActionMatcher(action).label(action.toString());
        }
        Checks.ensure(!(obj instanceof Boolean), "Rule specification contains an unwrapped Boolean value, " +
                "if you were trying to specify a parser action wrap the expression with ACTION(...)");

        throw new GrammarException("'" + obj + "' cannot be automatically converted to a parser Rule");
    }
View Full Code Here

                if (arg != null && !paramTypes[i].isAssignableFrom(arg.getClass())) continue outer;
                if (arg == null && paramTypes[i].isPrimitive()) continue outer;
            }
            return constructor;
        }
        throw new GrammarException("No constructor found for %s and the given %s arguments", type, args.length);
    }
View Full Code Here

                if (arg != null && !paramTypes[i].isAssignableFrom(arg.getClass())) continue outer;
                if (arg == null && paramTypes[i].isPrimitive()) continue outer;
            }
            return constructor;
        }
        throw new GrammarException("No constructor found for %s and the given %s arguments", type, args.length);
    }
View Full Code Here

            return new ActionMatcher(action).label(action.toString());
        }
        Checks.ensure(!(obj instanceof Boolean), "Rule specification contains an unwrapped Boolean value, " +
                "if you were trying to specify a parser action wrap the expression with ACTION(...)");

        throw new GrammarException("'" + obj + "' cannot be automatically converted to a parser Rule");
    }
View Full Code Here

TOP

Related Classes of org.parboiled.errors.GrammarException

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.