Improve block statements and import rules#64
Conversation
|
I think it would be better to use Exception for |
Is it? As far as I know, Lua is the only algol-like language that has explicit blocks. For now, I only wanted to rename to @ChrHorn, could you open an issue to revisit that idea later? |
Will do! |
| // Statements | ||
|
|
||
| _statement: $ => choice( | ||
| $.compound_statement, |
There was a problem hiding this comment.
What is the reason for the renaming? Aren't begin ... end block technically expressions? Same with let and if (and probably more), these are also expressions, right?
There was a problem hiding this comment.
Yes, they are. Julia is an expression based language and all forms are expressions that return some value.
_statement does conflate a few of things:
- Forms that hold blocks, like
quote … end - Forms that "never return" a value like
returnandbreak - Forms that can only be at the top-level, like
import
I would like to have a separate name for the first one, because we have quote_statement for quote … end and quote_expression for :(…). Similarly, we'd have compound_statement and parenthesized_expression, which aren't distinguished in the IR (they both form block Exprs). I think this is more consistent.
I have no opinion on the second category.
I don't think the third one should have any special treatment, because you can write those expressions inside quotes (which are not necessarily top-level).
_statement is a "subtype" of _expression in the grammar, so this more of a naming problem than a parsing problem.
`block` is the name used in Julia ASTs. See: https://docs.julialang.org/en/v1/devdocs/ast/#Block-forms
- Rename `compound_expression` to `compound_statement` - Fix empty `compound_statement` - Fix import/export statements - Add relative qualifiers - Add import aliases - Allow operators and macro identifiers in imports and exports - Make terminator in let statements mandatory - Update tests
_expression_listto_block. "block" is the name used in Julia ASTs. See: https://docs.julialang.org/en/v1/devdocs/ast/#Block-formscompound_expressiontocompound_statementCloses #13, closes #15, and closes #58 (duplicate)
Closes #28
Closes #59