-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels