Investigate addition of macros #6

Open
opened 2025-03-28 19:05:59 -04:00 by yukirij · 0 comments
Owner

Macros are a useful tool for reducing duplication and increasing legibility in code.

Proper Suzu macros would be scoped, likely using an ItemType to store the list of tokens in the macro.

Ideally, macros would also be grammatically incomplete, allowing for integration into broader expressions.

macro CALLBACK fn(a, b, c, d, e);

CALLBACK {
    # ...
}

It is likely that macros would require inserting tokens into the parser before reading from the tokenizer.

Additionally, collection of tokens would need to not involve the standard parser.
For single line statements, this could be done by reading tokens until a semicolon is reached; however, this would not work for multi-statement macros such as blocks.
Perhaps the macro expression could track open and close braces, ending in a semicolon once braces are paired.

Macros are a useful tool for reducing duplication and increasing legibility in code. Proper Suzu macros would be scoped, likely using an ItemType to store the list of tokens in the macro. Ideally, macros would also be grammatically incomplete, allowing for integration into broader expressions. ``` macro CALLBACK fn(a, b, c, d, e); CALLBACK { # ... } ``` It is likely that macros would require inserting tokens into the parser before reading from the tokenizer. Additionally, collection of tokens would need to not involve the standard parser. For single line statements, this could be done by reading tokens until a semicolon is reached; however, this would not work for multi-statement macros such as blocks. Perhaps the macro expression could track open and close braces, ending in a semicolon once braces are paired.
yukirij added the
investigation
label 2025-03-29 05:26:26 -04:00
Sign in to join this conversation.
No description provided.