Skip to content
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

Macro parsing a character literal containing a comma #142

Open
russells opened this issue Jan 30, 2025 · 5 comments
Open

Macro parsing a character literal containing a comma #142

russells opened this issue Jan 30, 2025 · 5 comments

Comments

@russells
Copy link

Looks like macro parsing of commas happens even inside a character literal.

Best illustrated with an example:

$ < t.asm awk '{print NR, "\t", $0}'
1               .pic32
2               li $t0, ','             ; OK
3        
4               .macro m(c)
5               li $t0, c
6               .endm
7        
8               m('A')                  ; OK
9               m(',')                  ; Error
$ naken_asm t.asm

naken_asm

Authors: Michael Kohn
         Joe Davisson
    Web: https://www.mikekohn.net/
  Email: [email protected]
Version: October 19, 2024

 Input file: t.asm
Output file: out.hex

Pass 1...
Error: Macro expects 1 params, but got only 2 at t.asm:9.
Pass 2...
Error: Macro expects 1 params, but got only 2 at t.asm:9.

Program Info:
Include Paths: .
               /usr/local/share/naken_asm/include
               include
 Instructions: 2
   Code Bytes: 8
   Data Bytes: 0
  Low Address: 0x0000 (0)
 High Address: 0x0007 (7)

$ 
@mikeakohn
Copy link
Owner

I'll see if I can look into this tonight.

mikeakohn added a commit that referenced this issue Feb 1, 2025
@mikeakohn
Copy link
Owner

Should be fixed with an extra unit test. Let me know how it goes...

@russells
Copy link
Author

russells commented Feb 2, 2025

Thank you, macro with a single quoted comma works now.

I've discovered a similar behaviour with a single quote.

This works

li $t0, '\''

But this doesn't

m('\'')

@mikeakohn
Copy link
Owner

The macro code has a different file reading code than the token code.. I forgot why I did that but I was hoping to get a chance to clean up that whole thing. I'll look into this and do a quick fix.

@mikeakohn
Copy link
Owner

That should take care of '''. Let me know how that goes.

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

No branches or pull requests

2 participants