Skip to content

Fix crash on macro calls with string arguments#3

Open
jamarju wants to merge 1 commit intoand3rson:mainfrom
jamarju:fix-string-args-in-macro-calls
Open

Fix crash on macro calls with string arguments#3
jamarju wants to merge 1 commit intoand3rson:mainfrom
jamarju:fix-string-args-in-macro-calls

Conversation

@jamarju
Copy link
Copy Markdown

@jamarju jamarju commented Mar 9, 2026

Summary

  • nice65 crashes with UnexpectedCharacters when encountering macro invocations that have double-quoted string arguments (e.g. HiAscii "BY DAN & KATHE")
  • Root cause: the grammar's operand rule only accepts registers and numeric/label expressions — no string literals
  • Fix: add a STRING terminal (/"[^"]*"/) and accept it as a valid alternative in the operand rule

Reproduction

        HiAscii "BY DAN & KATHE"

Before the fix:

lark.exceptions.UnexpectedCharacters: No terminal matches '"' in the current parser context

After the fix the line is parsed and formatted correctly.

Test plan

  • Verified the reproducer (HiAscii "BY DAN & KATHE") now parses and formats correctly
  • Verified multiple string args work (MyMacro "arg1", "arg2")
  • Verified samples/example.s output matches samples/clean.s exactly
  • Verified samples/example2.s -l output matches samples/clean2.s exactly

🤖 Generated with Claude Code

Add STRING terminal to the grammar and accept it as a valid operand,
so that macro invocations like `HiAscii "BY DAN & KATHE"` are parsed
correctly instead of raising UnexpectedCharacters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jamarju
Copy link
Copy Markdown
Author

jamarju commented Mar 10, 2026

Hello! Human here!

Found this issue while relabelling my VIC-20 Sargon II disassembly, looked for a cc65 asm beautifier, found your project, but it choked on the HiAscii macro. Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant