Skip to content

Conversation

@saranshflip
Copy link

What's changed?

Added debug test to investigate Java parser behavior with consecutive semicolons in import statements. Enhanced parser to detect and consume extra semicolons following import statements, storing them in the whitespace for accurate source representation.

What's your motivation?

Investigating a parsing issue where consecutive semicolons in import statements (e.g., import java.util.*;;) cause parser failures or generate incorrect LST with J.Erroneous nodes. This test helps identify the root cause and validates potential fixes.

Anything in particular you'd like reviewers to focus on?

Current Status: The parser now bypasses the parsing error and generates an LST tree, but the tree contains J.Erroneous nodes which indicates the fix is incomplete.

Key concerns:

  • The LST structure is not correctly representing the consecutive semicolons
  • J.Erroneous nodes suggest the parser is still struggling with this syntax
  • Need guidance on proper tree generation for this edge case

Would appreciate feedback on:

  • Correct approach to handle extra semicolons in the grammar/parser
  • How to properly store consecutive semicolons in the LST without creating erroneous nodes
  • Whether the whitespace approach is the right strategy

Anyone you would like to review specifically?

Looking for maintainers familiar with the Java parser implementation and LST tree generation.

Have you considered any alternatives or workarounds?

  1. Current approach: Storing extra semicolons in whitespace partially works but creates erroneous nodes
  2. Alternative: Modifying the grammar to explicitly handle consecutive semicolons
  3. Workaround: Pre-processing source to normalize consecutive semicolons before parsing

Any additional context

This is a work-in-progress contribution. The debug test successfully identifies the issue and the current fix prevents parse failures, but the LST generation needs refinement. The test includes comprehensive debugging output to help understand the parser's behavior with malformed import statements.

Test output shows:

  • Parser no longer fails completely
  • LST tree is generated but contains erroneous nodes
  • Source round-trip may not be perfect due to incorrect tree structure

Seeking guidance on the proper implementation to generate a clean LST without J.Erroneous nodes.

Enhanced the parser to detect and consume extra semicolons following import statements, storing them in the whitespace for accurate source representation. Added a debug test to verify import parsing and whitespace handling.
Refine comment for clarity in parsing success case.
timtebeek and others added 2 commits December 4, 2025 12:53
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@timtebeek timtebeek added bug Something isn't working java parser labels Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working java parser

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants