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

"partial" regexps (<#FOO>) cause false-positive warnings #17

Closed
dweiss opened this issue Sep 18, 2020 · 8 comments
Closed

"partial" regexps (<#FOO>) cause false-positive warnings #17

dweiss opened this issue Sep 18, 2020 · 8 comments
Milestone

Comments

@dweiss
Copy link

dweiss commented Sep 18, 2020

Thank you for the plugin. It is helpful. I just wanted to point out that currently "partial" regexp definitions cause warnings. Something like:

<DEFAULT> TOKEN : {
      <#_NUM_CHAR:   ["0"-"9"] >
    // Every character that follows a backslash is considered as an escaped character
    | <#_ESCAPED_CHAR: "\\" ~[] >
    | <#_TERM_START_CHAR: ( ~[ " ", "\t", "\n", "\r", "\u3000", "+", "-", "!", "(", ")", ":", "^", "@",
    | <PLUS:          "+" >
...

would bring a warning like this:

"+" cannot be matched as the string literal token <PLUS>, _TERM_CHAR matches its input instead 

This isn't true because pound-starting definitions don't generate tokens of their own - they're just expanded into final tokens, if used.

@oowekyala
Copy link
Owner

Thanks for the report, I'll try to find time for this shortly

@dweiss
Copy link
Author

dweiss commented Sep 18, 2020

No worries. Thank you!

@oowekyala
Copy link
Owner

So I've been looking into this bug and am having trouble reproducing it... The example you provide has a syntax error, and even if corrected, I don't see an issue (even when adding tokens like your _TERM_CHAR). Could you provide a minimal working example?

@dweiss
Copy link
Author

dweiss commented Sep 19, 2020 via email

@dweiss
Copy link
Author

dweiss commented Sep 19, 2020

This is a smaller example that reproduces the problem.

PARSER_BEGIN(Example)
public class Example {
}
PARSER_END(Example)

<DEFAULT> TOKEN : {
      <#_FRAGMENT:   ["0"-"9"] >
    | <QUOTED:        "\"" ( <_FRAGMENT> )* "\"">
    | <ZERO: "0" >
}

public Void Rule() :
{
}
{
  <QUOTED> | <ZERO>
  {
   return null;
  }
}  

Note how QUOTED uses the fragment to define a regexp that contains it. The fragment will never match on its own but the plugin claims a conflict with token ZERO.

@oowekyala
Copy link
Owner

Misclick

Thanks, I'll look into this tomorrow

@oowekyala oowekyala reopened this Sep 19, 2020
@dweiss
Copy link
Author

dweiss commented Sep 20, 2020 via email

@oowekyala oowekyala added this to the 1.7 milestone Sep 20, 2020
oowekyala added a commit that referenced this issue Sep 20, 2020
@oowekyala
Copy link
Owner

I was able to reproduce the bug, it should be fixed in version 1.7, which I'll release sometime this week. Thanks for your cooperation Dawid !

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

2 participants