Closed zerbina closed 1 month ago
One thing that's also not present, when compared to NimSkull, is the style-insensitivity for identifiers. Personally, I like NimSkull's style-insensitivity rules, and they're something I would also add to Phy, but it's not something that should happen as part of this PR.
In order to not treat declarations as expression, the language grammar grammar needs to be extended with groups, so that the Exprs
grammar can be changed to:
(Exprs (<local_decl>* <expr>)+)
*
matches greedily, which is why (Exprs <expr_or_decl>* <expr>)
cannot work.
~I'll make a separate PR for this extension.~
Edit: For the moment, it's simpler to treat declarations as expressions, so I'm not going to change the current behaviour. Treating declarations as expression might also be the better long-term direction.
Summary
Decl
)Asgn
)Details
Language
The specification for assignments already covers the copy/move/ destruction behaviour, although there's current no way to test it.
Current Limitations
For the initial version, the additions are kept as simple as possible. Notably:
The plan is to lift/remove all of the above limitations/restrictions/ shortcomings at a later date.
Source2IL
exprToIL
now returns theExprType
type, which carries additional expression attributes. At the moment, this is only theLvalue
attribute+
operator is added, for constructingExprType
valuesexprToIL
are updatedscopedExprToIL
is added, for analyzing an expression within a new nested scopeTests are added to ensure the declarations and assignments work as specified.
To-Do