Repository navigation
Conversation
…hed in The literal table held, for each literal of each lexical state, the NFA start state recorded for its kind, which is the one of the lexical state processed last. A literal declared in more than one lexical state (<*> for instance) then continued in the NFA of another lexical state. Uses TokenizerData.getNfaStartState(lexState, kind), which requires a core that has it. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new call to TokenizerData.getNfaStartState(int, int) is unavailable in the default core dependency version 8.1.0, preventing compilation until the dependency is updated.
1 open issue
What changed in this PR
Updates the Java token-manager generator so string literals use the NFA start state of their lexical state, addressing literals that continue differently across lexical states.
Changes:
- Replaces the token-kind-only lookup with
getNfaStartState(key >> 16, kind), passing both lexical state and token kind to the core API.
| File | Description |
|---|---|
src/main/java/org/javacc/java/TokenManagerCodeGenerator.java |
Emits lexical-state-specific NFA start states in the generated string-literal table. |
Review effort: Balanced
| } | ||
| jcb.print(", " + kind); | ||
| jcb.print(", " + tokenizerData.kindToNfaStartState.get(kind)); | ||
| jcb.print(", " + tokenizerData.getNfaStartState(key >> 16, kind)); |
Author
There was a problem hiding this comment.
Yes, as the description says, this depends on javacc/javacc-8-core#8. javacc.core.version is defined in the parent pom (javacc/javacc-8), so it cannot be changed from this repository; it needs a core release or snapshot that has the accessor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes javacc/javacc-8#8 for the Java generator: the
stringLiteralstable of the generated token manager now holds, for each literal of each lexical state, the NFA start state of that lexical state, throughTokenizerData.getNfaStartState(lexState, kind).This needs javacc/javacc-8-core#8: it does not compile against core 8.1.0, so
javacc.core.versionhas to point at a core that includes it before this can be merged.Checked by building against the patched core: the token managers generated for the issues, examples and grammars of this repository are byte for byte the same as before (none of them has a literal continued differently in two lexical states), and the Commons JEXL grammar gets the same token streams as with JavaCC 7.
🤖 Generated with Claude Code