Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected end of input when using uppercase letter #2

Open
mbatchkarov opened this issue Jul 12, 2016 · 0 comments
Open

Unexpected end of input when using uppercase letter #2

mbatchkarov opened this issue Jul 12, 2016 · 0 comments

Comments

@mbatchkarov
Copy link

Hi,

I noticed a weird corner case when using uppercase letters in a regex. The following example parses fine:

final String grammar =
        "/nlp/\n" +
                "sent <- goo* name goo*\n" +
                "name <- 'Miro' \n" +
                "goo <- [0-9] / [a-z]/ ' '\n"; // adding  "/ [A-Z]" here breaks it

String txt = "hello Miro how are you";
try (GramExp peg = new GramExp(grammar)) {
    System.out.println(peg.parse(txt));
}

whereas the next two examples fail. I am only adding support for uppercase letters:

final String grammar =
        "/nlp/\n" +
                "sent <- goo* name goo*\n" +
                "name <- 'Miro' \n" +
                "goo <- [0-9] / [A-Z]/ ' '\n"; // adding  "/ [A-Z]" here breaks it

String txt = "HELLO MIRO HOW ARE YOU";
try (GramExp peg = new GramExp(grammar)) {
    System.out.println(peg.parse(txt));
}

and

final String grammar =
        "/nlp/\n" +
                "sent <- goo* name goo*\n" +
                "name <- 'Miro' \n" +
                "goo <- [0-9] / [a-zA-Z]/ ' '\n"; // adding  "/ [A-Z]" here breaks it

String txt = "hello Miro How are you";
try (GramExp peg = new GramExp(grammar)) {
    System.out.println(peg.parse(txt));
}

The error is:
Exception in thread "main" uk.ac.susx.tag.gramexp.GrammarException: Unexpected end of input, expected goo or name (line 1, pos 23)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant