savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
153 stars 12 forks source link

BREAKING CHANGE: Macros now have weaker parsing precedence. #463

Closed jemc closed 1 year ago

jemc commented 1 year ago

That is, whitespace-delimited terms (such as those used by if, while, etc) now bind more weakly than all relation operators, except for the specific case of assigning operators (=, +=, -=, etc).

The savi format utility will remove a lot of now-unnecessary parens. For example, most if statements will now no longer need parens around their condition expression (unless it is complex enough to need it). See the diff in this PR for many examples of auto-removed parens.

This is a breaking change because you may need to add parens around some macro use sites. For example, an expression like:

    a = b + if (c < 0) (d | e)

Will now be written like:

    a = b + (if c < 0 (d | e))

Because otherwise the b + would try to bind tightly to the if word alone, isolating the if term from its conditional and body expressions.