Repository navigation
feat(common): move the WIT ast parser to tools/common and add a lenient mode - #73
Merged
Merged
Conversation
…nt mode The WIT parser lived on the wit branch while the Kotlin wasm rules and please_wit both parsed WIT with regexes. Moving it to main lets every branch share it. Lenient mode skips declarations it does not model (use, variant, flags, include) for callers that only need names; the strict mode now reports them by name instead of a token-type error. Item 3 of #66. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
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.
Item 3 of #66, step 1: the shared parser.
please_wit(wit branch) andplease_kotlin_wasm(kotlin branch) both read WIT with regexes (worldRegex,packageRegex,funcRegex,ifaceRegex...), which break on comments,package a:b@1.0;, multi-line functions, or two declarations on one line. The wit branch already has a real lexer and parser (ast); this moves it totools/common/wit/astunchanged, so both branches can use it (follow-up PRs).Additions:
ParseContentLenient/ParseFileLenient: skip declarations the parser does not model (use,variant,flags,include), for callers that only need names, like world and package discovery. Without it, a file with ausestatement would make discovery fail where the regex used to work.line N: "use" declarations are not supportedinstead ofexpected token type 2, so a generator never silently drops a variant.use x.{y}/type/recorddeclaration so its braces cannot end the world early.27 existing tests unchanged and passing, 3 new (30 total).
🤖 Generated with Claude Code