Skip to content

v3.1.0

Compare
Choose a tag to compare
@aspizu aspizu released this 16 Mar 11:05
· 232 commits to main since this release

goboscript v3.1.0 Release Notes

This release features a refactored pre-processor that fixes several issues, paves the way for new features, and gracefully handles errors.

CONCAT Macro

  • Functionality: Joins two tokens into a single token.
  • Syntax Example:
    CONCAT(LHS, RHS)
    
    # becomes
    
    LHSRHS
    
  • Nesting Support: CONCAT can be nested, for example:
    CONCAT(PREFIX, CONCAT(NAME, SUFFIX))
    
    # becomes
    
    PREFIXNAMESUFFIX
    
  • Limitation: Currently, only name tokens can be joined.

Recursive Macros

  • Improvement: Recursive macros (macros that reference their own name in their definition) are now handled gracefully. Once a macro is expanded, it is marked as suppressed to avoid re-evaluation in the same substitution pass, preventing hangs and infinite loops.

Parsing Ambiguity: Variable-like vs Function-like Macros

  • Issue: When defining a variable-like macro whose definition starts with a ( token, if the token following is a name, it may be misinterpreted as a function-like macro.
  • Solution: To ensure proper parsing, additional parentheses are required. For instance, defining %define unit_range (zero,one) now requires extra parentheses:
    %define unit_range ((zero,one))
    

Recommended Conventions for Macros

  • Function-like Macros: Use these to clearly indicate that the macro expands into an expression (e.g. IS_HOVERED() instead of IS_HOVERED), which avoids confusion with global variables.
  • Naming: Uppercase naming is recommended for macros.
  • Constants: For constants, consider using variable declarations (e.g. var EXAMPLE = 2*(3+4);) if constant-folding optimizations are not required.

Enjoy the improved syntax and reliability of goboscript v3.1.0!

Changelog

  • 40ec4e7 add nix flake
  • e8022e0 add nix flake (#117)
  • c99046c bump: update dependencies to latest versions
  • 3f0a3f5 bump: update goboscript version to 3.1.0
  • f902953 chore: remove unused dependencies and commented code
  • c12e988 feat: add concat macro
  • 443f22d fix: parsing & substitution of zero-parameter function-like macros
  • 7374c8c pre processor rewrite (#118)
  • 0240d91 refactor: pre-processor v2
  • 0b56f65 refactor: pre-processor.rs using AI. (could lead to regressions?)
  • a074b33 refactor: update return type of PreProcessor::define to Result<(), Diagnostic>

Released by GoReleaser.