[Issue 216] New - Java 1.5 grammar lookahead problem

View: New views
4 Messages — Rating Filter:   Alert me  

[Issue 216] New - Java 1.5 grammar lookahead problem

by xlv-java.net :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://javacc.dev.java.net/issues/show_bug.cgi?id=216
                 Issue #|216
                 Summary|Java 1.5 grammar lookahead problem
               Component|javacc
                 Version|4.2
                Platform|All
              OS/Version|All
                     URL|
                  Status|NEW
       Status whiteboard|
                Keywords|
              Resolution|
              Issue type|DEFECT
                Priority|P3
            Subcomponent|parser generator
             Assigned to|sreeni
             Reported by|xlv






------- Additional comments from xlv@... Sun Dec 14 21:46:32 +0000 2008 -------
A bug report for PMD was submitted with a Java parsing problem. The grammar used
by PMD is pretty similar to the one in examples/JavaGrammars/1.5/Java1.5.jj.

To reproduce the problem, use the class:

public class BadClass {
        public Class foo() {
                return (byte[].class);
        }
}

Note that the problem occurs only for primitive types, (String[].class) is
parsed correctly. It's somewhere in the CastLookahead rule but I haven't figured
it out yet...

Xavier

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 216] Java 1.5 grammar lookahead problem

by tcopeland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://javacc.dev.java.net/issues/show_bug.cgi?id=216



User tcopeland changed the following:

                What    |Old value                 |New value
================================================================================
             Assigned to|sreeni                    |tcopeland
--------------------------------------------------------------------------------




------- Additional comments from tcopeland@... Thu May 14 01:13:22 +0000 2009 -------
I think this can be resolved by removing the first part of the lookahead, e.g.:

 void CastLookahead():
 {}
 {
-  LOOKAHEAD(2)
-  "(" PrimitiveType()
-|
-  LOOKAHEAD("(" Type() "[")
+  LOOKAHEAD("(" Type() "[" "]" ")")
   "(" Type() "[" "]"
 |
   "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" |
Literal() )

I've been trying to find any problems that this causes and nothing yet...

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 216] Java 1.5 grammar lookahead problem

by xlv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://javacc.dev.java.net/issues/show_bug.cgi?id=216






------- Additional comments from xlv@... Thu May 14 05:49:06 +0000 2009 -------
As I just commented on the PMD report, it doesn't work when parsing Long.java
from the SDK as the primitive test is still needed.

  result = negative ? new Long((long)-result.longValue()) : result;

is the line where the problem occurs.

BTW, Tom, thanks for looking at the issue.


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...


[Issue 216] Java 1.5 grammar lookahead problem

by tcopeland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

https://javacc.dev.java.net/issues/show_bug.cgi?id=216






------- Additional comments from tcopeland@... Tue Sep 29 00:30:58 +0000 2009 -------
Only 4 months later, I have another suggestion :-)  

What if we change the primitive type token lookahead from 2 to 3?

=========
void CastLookahead():
{}
{
    LOOKAHEAD(3)
    "(" PrimitiveType() ")"
  |
    LOOKAHEAD("(" Type() "[")
  "(" Type() "[" "]"
|
  "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" |
Literal() )
}
=========

I ran this on the JDK source and didn't get any parsing failures - at least,
none that were related to this change.  Can you give it a whirl?


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@...
For additional commands, e-mail: issues-help@...