-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
NoViableAltException: no viable alternative at input '(' #124
Comments
Hi @Chadehoc,
Right! Looks like you've run into a parsing error. Potential causes
Minimal reproducible caseWithout a minimal reproducible case, this might be hard to figure out. Option 1: Do it yourselfTry the following steps:
If the parsing error is still present after step 1, then the problem is somewhere else in the file. Option 2: Let me do it for youYou're welcome to send the problematic file through to me:
|
First reason found, a combination of:
I should be able to make a minimal example for that. But now I have another parsing error, in another unit (but similar pattern) which resists to emptying the local types. I'm still investigating. |
I'd be surprised if the grammar couldn't handle valid identifiers. Just a stab in the dark, have you configured the encoding for the project via Could you give an example of such an identifier from this code? |
My apologies, I had misremembered this a bit. I thought we handled this correctly because I looked into it a while ago and documented all the quirks in delphi unicode identifiers. We only actually fixed the whitespace issues that I discovered at that time (in #39). I'll raise a new issue shortly for full unicode identifier support. |
Thanks! Non-ANSI characters finally explain much of those parsing errors (in my case, always a french "é" or "è", as in Now I have other exceptions thrown:
Should I open a new issue? Or investigate further first? |
Hello @Chadehoc,
This is a problem in itself, I think.
Yes please!
This is pretty interesting to me, as all known file position calculation issues were ironed out quite a long time ago. Thanks for following up with this new information, by the way. |
Should I change the issue subject to "Confusing parsing error reports when non-ANSI characters in identifiers"? Because finally, the following was another example of it:
While trimming down a minimal example, I noticed once again a
|
No need, I'll raise a separate issue and just link it to this one.
Great! Seems like #125 is (knock on wood) going to fix all of the parsing errors, then. That just leaves the 2 file pointer issues you mentioned. |
And still the same! In the reported lines, trailing comments (after some instructions) were having accentuated characters (and these are expected in French comments!). I suppose the "exotic" characters are wrongly counted in the line length. Fortunately, this only causes an issue when the line (including the comment) is too long. |
This would make a lot of sense. Maybe one part is counting characters and the other is counting bytes. |
One way to get around this issue for now would be to disable the rule entirely in a custom quality profile via the sonarqube web interface. |
@Chadehoc I wasn't able to reproduce the issue with the non-ASCII characters causing line offset errors in end-of-line comments. Would you be able to provide an example that reproduces the issue? |
Is it possible that the line pointer issues are due to a multiline compiler directive earlier in the file? 1.0.0 has a bug in which compiler directives that span multiple lines cause file pointer errors - it was raised in #88 and fixed earlier this month in master. |
No multiline compiler directives in my case. Here is an example line causing the mismatch (UTF-8). Splitting the comment to another line fixed it. |
Looks we've identified all of the issues, then! Closing this one, and we'll focus on: |
Prerequisites
SonarDelphi version
1.0.0
SonarQube version
10.3.0.82913
Issue description
I encountered this error, and could not isolate its cause, so this bug report is for the moment an inquiry of what to look for (to report it correctly).
The top of the stack is:
and the
'('
token is that afterclass
in:This pattern (same parent class) was processed before without problems in another project, as well as in the same project in a previously processed file (as traced with the
-X
option tosonar-scanner.bat
).The result is the same if I configure the projet to Delphi 11 or Delphi 12 (projects and code are different, but this piece of code is the same).
I'm juste trying out SonarQube: I followed the "Try out SonarQube" page, and sonar-delphi's README. From the trace: SonarScanner 5.0.1.3006, Java 17.0.7 Eclipse Adoptium (64-bit), Windows 10 10.0 amd64, SonarQube server 10.3.0.82913 (community).
Steps to reproduce
I'm asking for a clue to try to isolate the error. I looked at the unit processed just before this one (in the trace) and could find nothing exotic, either. Our code base is huge.
Minimal Delphi code exhibiting the issue
No response
The text was updated successfully, but these errors were encountered: