matthiasblaesing commented on code in PR #9258:
URL: https://github.com/apache/netbeans/pull/9258#discussion_r2918191450


##########
java/java.lexer/src/org/netbeans/lib/java/lexer/JavaLexer.java:
##########
@@ -1196,7 +1196,9 @@ else if ('0' <= c && c <= '9') { // float literal
                                             next = nextToken();
                                         } while (next != null && 
AFTER_VAR_TOKENS.contains(next.id()));
 
-                                        varKeyword = next != null && next.id() 
== JavaTokenId.IDENTIFIER;
+                                        varKeyword = next != null
+                                                && (next.id() == 
JavaTokenId.IDENTIFIER
+                                                || next.id() == 
JavaTokenId.UNDERSCORE);
                                     }
 
                                     input.backup(input.readLengthEOF()- len);

Review Comment:
   Just an observation and _not_ intended to stop this:
   
   This whole code is problematic. Its existence breaks JShell support for 
`var`. The nested language infrastructure breaks when backtracking is used in 
this manner. I suspect the issue here is that this is not just backtracking, 
but backtracking over token boundaries.
   
   You can test this by opening "Tools" -> "Open Java Platform Shell", input 
`var s = "String";` and try to let that be evaluated. "Enter" is not accepted 
and you can observe exception on command line.
   
   With the backtracking code removed (see: 
https://github.com/matthiasblaesing/netbeans/commit/0f4f15cbf3ec1ab30e19032288d8efccf39834f8
 (first commit of 
https://github.com/matthiasblaesing/netbeans/commits/jshell_lexer2/ and 
inspired by @lahodaj approach in a different PR) execution is at least done 
(there are still problems there).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to