Skip to content

4.6 :RegularExpressionParser is broken #30

@xgillard

Description

@xgillard

Concerns : JaCoP 4.6 (Java 11).

I spotted a few issues in the code of the RegularExpressionParser class introduced in 4.6.

  • (this one is fixed in the enclosed patched file) the class is unusable since the result of lexer.nextToken() is never used. As a consequence of that, any call to parse yields 'null'.
  • The dot notation parsing is flaky. For instance, the following two examples relate toi the handling of epsilon expressions but are not orthogonal to one another.
// Prints "null.(32)*"
System.out.println(new PatchedRegexParser(new StringReader("(.32*)")).parse(false));

// Warns of a syntax error then prints "32.(null).*"
System.out.println(new PatchedRegexParser(new StringReader("(32.*)")).parse(false));
  • In some cases (ie when a dot is missing) the parser silently drops a whole portion of the text to parse. For example, consider the following example:
// Prints "(17)*.23" and nothing more.
System.out.println(new PatchedRegexParser(new StringReader("(32.14*)17*.23")).parse(false));

Btw, I wonder if reusing the . and + symbols for summation and concatenation was judicious. Indeed, these symbols have different meaning in POSIX-style regexes (and I assume most people would expect that meaning)

PatchedRegexParser.java.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions