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

RGBDS syntax updates #905

Merged
merged 13 commits into from
Jun 6, 2022
Merged

RGBDS syntax updates #905

merged 13 commits into from
Jun 6, 2022

Conversation

vulcandth
Copy link
Collaborator

@vulcandth vulcandth commented Apr 15, 2022

Implementing the new RGBDS Macro Syntax. This was done using regex. It make compare OK. Although, Please review thoroughly to make sure I didn't change something I shouldn't have.

Please also reference: #686

@Rangi42
Copy link
Member

Rangi42 commented Apr 17, 2022

Looks good, thanks! I assume it was something like s/^([A-Za-z_][A-Za-z0-9_@#]*): MACRO/MACRO \1/g?

Please add DEF to constants in this PR as well. I thought that would be too disruptive, but after all, most constants are done with const and the DEFs would mostly be within macros anyway. A regex like s/^([A-Za-z_][A-Za-z0-9_@#]*\s+(?:EQU\b|EQUS\b|=|rb\b|rw\b|rl\b))/DEF \1/g should cover all of them, but then it'll be nice to manually indent ones inside of macros (since that's one reason rgbasm introduced the DEF syntax anyway).

@vulcandth
Copy link
Collaborator Author

vulcandth commented Apr 17, 2022

@Rangi42 I added DEF in front of the constants. I have not yet indented the constants in the MACRO's. I plan to go back through an manually tackling that. Could you please give one or two examples of how you like it indented.. and i'll apply it to the rest.

EDIT: nevermind I saw in discord an example.

@Rangi42
Copy link
Member

Rangi42 commented Apr 17, 2022

Oops, I forgot to get the new +=/-=/etc operators in that regex (like __deco_value__ += 1).

s/^([A-Za-z_][A-Za-z0-9_@#]*\s+[-+*/%<>&|^]=)/DEF \1/g will update them. Some also need indenting.

@Idain
Copy link
Contributor

Idain commented Apr 17, 2022

I still think that Regex is advanced sorcery, so I'm very impressed.

@Rangi42
Copy link
Member

Rangi42 commented Apr 17, 2022

I think this is ready now. @aaaaaa123456789 @mid-kid want to review?

I still think that Regex is advanced sorcery, so I'm very impressed.

They're literally simpler than complete programming languages, it's just that they have a very dense syntax, and it can be hard to read which characters are regex language operators vs which are literal text. Python has a verbose regex mode that lets you space things out and add comments, like:

^                   # Start at the beginning of the line
(                   # Capture all this text so we can refer to it in the 'DEF \1' replacement
  [A-Za-z_]         # Constants start with a letter or '_'
  [A-Za-z0-9_@#] *  # Constants may then have letters, digits, '_'s, '@'s, or '#'s
  \s +              # At least one whitespace character between the constant and the operator
  [-+*/%<>&|^]      # The first character of '-=', '+=', '*=', etc
  =                 # The second character is always an '='
)

People have also made various alternative syntaxes that some might find easier to read/write.

@vulcandth vulcandth changed the title New MACRO Syntax RGBDS Macro Syntax and DEF Prefix Updates Apr 17, 2022
@vulcandth vulcandth changed the title RGBDS Macro Syntax and DEF Prefix Updates RGBDS Syntax Updates Apr 19, 2022
Copy link
Contributor

@aaaaaa123456789 aaaaaa123456789 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a few minor things. Nice work!

audio/engine.asm Outdated Show resolved Hide resolved
constants/hardware_constants.asm Outdated Show resolved Hide resolved
constants/script_constants.asm Outdated Show resolved Hide resolved
constants/serial_constants.asm Outdated Show resolved Hide resolved
constants/text_constants.asm Show resolved Hide resolved
macros/vc.asm Show resolved Hide resolved
maps/CeladonGameCornerPrizeRoom.asm Outdated Show resolved Hide resolved
maps/GoldenrodGameCorner.asm Outdated Show resolved Hide resolved
mobile/mobile_42.asm Outdated Show resolved Hide resolved
wram.asm Outdated Show resolved Hide resolved
vulcandth and others added 4 commits April 20, 2022 19:25
This partially reverts commit 3052c6c.
Co-Authored-By: aaaaaa123456789 <aaaaaa123456789@acidch.at>
Co-Authored-By: aaaaaa123456789 <aaaaaa123456789@acidch.at>
Co-Authored-By: aaaaaa123456789 <aaaaaa123456789@acidch.at>
@Rangi42
Copy link
Member

Rangi42 commented Apr 26, 2022

Updating the MACRO and DEF syntaxes here looks good to me. It should wait to merge until all four repos are ready.

Copy link
Collaborator Author

@vulcandth vulcandth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a couple things that still need fixing while doing pokegold.

constants/map_constants.asm Outdated Show resolved Hide resolved
data/maps/attributes.asm Outdated Show resolved Hide resolved
sram.asm Outdated Show resolved Hide resolved
@Rangi42 Rangi42 changed the title RGBDS Syntax Updates RGBDS syntax updates May 6, 2022
@Rangi42 Rangi42 merged commit 3648afd into pret:master Jun 6, 2022
@vulcandth vulcandth deleted the MacroUpdate branch October 13, 2022 03:30
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.

4 participants