-
-
Notifications
You must be signed in to change notification settings - Fork 2
Add lino! macro for compile-time Links Notation parsing in Rust #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #201
Implement a procedural macro that provides compile-time validation and convenient syntax for working with Links Notation in Rust. Features: - Compile-time syntax validation with clear error messages - Zero runtime overhead for validation - Returns fully typed LiNo<String> structures - Simple and ergonomic API Implementation: - Created links-notation-macro crate with procedural macro - Added basic syntax validation (parentheses, quotes) - Re-exported macro from main crate via 'macro' feature (enabled by default) - Added comprehensive test suite with 12 test cases - Updated documentation with macro usage examples The macro validates syntax at compile time and calls the runtime parser, providing the best of both worlds: compile-time error checking and full parser capabilities. Related to #201 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This reverts commit 87b5e54.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Can we also support direct lino inclusion into the code without |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-14T17:03:59.151Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
The lino! macro now supports writing Links Notation directly without
string literals, providing a more native and cleaner syntax:
lino!(papa (lovesMama: loves mama))
instead of:
lino!("papa (lovesMama: loves mama)")
Both syntaxes are supported - string literals are still needed for
special cases like newlines, quoted strings with spaces, or indented
syntax.
Implementation:
- Add custom token parser (DirectLinoInput) that converts Rust tokens
to Links Notation string representation
- Handle identifiers, punctuation, literals, and groups (parentheses)
- Support colons for ID separators in Links Notation
- String literal syntax takes precedence for backward compatibility
Testing:
- Add 15 new tests for direct syntax
- Test equivalence between direct and string literal syntaxes
- Test runtime parser equivalence
- All 27 macro tests passing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Direct Syntax Support AddedI've implemented the requested feature to support direct lino inclusion without quotes. What's NewThe // Direct syntax - cleaner and more native!
let result = lino!(papa (lovesMama: loves mama));
let triplet = lino!(papa has car);
let nested = lino!((outer: (inner: value)));String Literal Syntax Still SupportedString literals are still needed for complex cases: // Newlines
let multiline = lino!("papa has car\nmama has house");
// Quoted strings with spaces
let quoted = lino!(r#"("quoted id": "quoted value")"#);
// Indented syntax
let indented = lino!(r#"3:
papa
loves
mama"#);Implementation Details
The PR is now ready for review! |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
🔄 Auto-restart 1/3Detected uncommitted changes from previous run. Starting new session to review and commit them. Uncommitted files: Auto-restart will stop after changes are committed or after 2 more iterations. Please wait until working session will end and give your feedback. |
Add patterns to ignore target/ and Cargo.lock in Rust sub-crates (e.g., rust/links-notation-macro/). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Why separate package for links-notation-macro? Can we integrate everything inside links-notation package, and also may be reuse some parsing logic? And tests should be in separate files, not with logic please. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-15T02:46:23.899Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
- Move tests from lib.rs to tests.rs in links-notation-macro crate - Mark doc examples as `ignore` since they reference links_notation which can't be a dependency of a proc-macro crate - Keep test logic and implementation logic in separate files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests Separated from LogicI've moved the unit tests from Regarding Separate Package for MacroAbout integrating everything inside the
This is the standard pattern used by major Rust crates like What I've done
|
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
If we cannot have the shared code, please make sure we have structure: So it will be crystal clear the rust version has 2 distinct packages based on the file structure of the project. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-15T07:53:58.473Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Move main crate from rust/ to rust/links-notation/ so the project structure clearly shows two distinct packages: - rust/links-notation/Cargo.toml - rust/links-notation-macro/Cargo.toml This makes the architecture visible from the directory structure, as requested in PR feedback. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add rust/Cargo.toml as workspace root including both packages - Update CI workflow to read package info from links-notation/Cargo.toml - Update cargo publish to specify -p links-notation - Fix clippy warning in macro crate (collapsible_match) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Directory Structure ReorganizedI've reorganized the Rust project structure as requested. The new structure clearly shows two distinct packages: Changes Made
Architecture ClarificationSince proc-macro crates must be separate crates (Rust compiler requirement), the project has 2 packages:
Users only need to depend on All tests pass (257 total) and CI checks are green. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
Summary
This pull request implements the
lino!macro for compile-time Links Notation parsing support in Rust, addressing issue #201.New Feature: Direct Syntax Support
The macro now supports writing Links Notation directly without quotes:
String literal syntax is still supported for complex cases:
Fixes
Fixes #201
Features Implemented
1. Direct Syntax Support (New)
Write Links Notation directly without quotes:
lino!(papa has car)lino!(papa (loves mama))lino!((myId: value1 value2))lino!((a: (b: (c: d))))2. String Literal Syntax (Original)
For complex cases with special characters:
lino!("line1\nline2")lino!(r#"("my id": "my value")"#)lino!(r#"id:\n child"#)3. Compile-Time Validation
Technical Implementation
Architecture
DirectLinoInputthat converts Rust tokens to Links Notation stringtokens_to_lino_stringfunction that processes identifiers, punctuation, literals, and groupsCode Changes
rust/links-notation-macro/src/lib.rs: Enhanced macro with direct syntax supportrust/tests/macro_tests.rs: Added 15 new tests for direct syntax (27 total)rust/README.md: Updated documentation with direct syntax examplesTesting
Test Suite:
rust/tests/macro_tests.rsWhen to Use Each Syntax
lino!(papa has car)lino!(papa (loves mama))lino!((myId: value))lino!("line1\nline2")lino!(r#"("my id": "my value")"#)lino!(r#"id:\n child"#)Code Quality
cargo fmt --checkpassescargo clippy -- -D warningspassesChecklist
Impact
This PR was created automatically by the AI issue solver
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com