Allow literals in quote and interpolation expressions.
Allow strings and prefixed strings in field_expression RHS.
Replace true and false with boolean_literal.
Allow backslash to escape any character (that's how command_literal works).
Define escape_sequence as a constant, not a grammar rule (to parse character_literal as a single token).
Add string and command suffixes.
Refactor float_literal.
Identifiers and operators
Refactor quote_expression.
Add syntactic operators to quote_expression (e.g. :.).
Define constants for lazy logic operators.
Split adjoint_expression from unary_expression.
Add more math symbols to identifier.
Allow begin as an identifier.
Allow parenthesized identifier/operators in more places.
Primary expressions
Refactor quote_expression.
Add curly_expression and _immediate_brace rule to scanner (for macro DSLs).
Allow interpolation_expression in more places.
Replace scoped_identifier with field_expression in function names. Function names already allow interpolations, so allowing more primary expressions isn't that bad. (e.g. function $M.$f(x) end).
Juxtapositions
Rename coefficient_expression to juxtaposition_expression.
Allow any _primary_expression in RHS of juxtaposition_expression.
tuples and function arguments
Allow arbitrary expressions in named tuples and keyword arguments.
Allow mixing expressions and named fields in tuples.
Allow call_expression in parameter list (for Gen.jl).
Assignments
Define let_binding in terms of named_field.
Allow assignments in return_statement.
Allow simple bindings (named fields) in arrays and string_interpolation.
Allow declarations in parenthesized_expression.
Allow nested named fields.
Allow quote_expression in assignments' LHS.
Parse .= as compound_assignment_expression, not assignment.
Allow typed_parameter in for_binding.
Allow _declaration in macro_argument_list.
Tests
Remove Mocha.jl. It's been deprecated since 2018.
Update repo versions
Add Pluto.jl as an example repo. Pluto:
Is currently the most popular Julia project on github
Is a large Julia Project (20kloc)
Uses a lot of metaprogramming
Uses a lot of emojis
Closes #7
Closes #35
Closes #84
This PR has two goals:
Adding things I missed in #83.
Improving the way the grammar handles metaprogramming, DSLs and some questionable practices.
While it doesn't stand out, one of the most important changes is the extension of valid juxtapositions. tree-sitter has very poor support for explicit whitespace handling, so like in other whitespace sensitive cases, this is a best-effort approximation. It also results in a much more bloated src/parser.c.
Literals
field_expression
RHS.true
andfalse
withboolean_literal
.command_literal
works).escape_sequence
as a constant, not a grammar rule (to parsecharacter_literal
as a single token).float_literal
.Identifiers and operators
quote_expression
.quote_expression
(e.g.:.
).adjoint_expression
fromunary_expression
.identifier
.begin
as an identifier.Primary expressions
quote_expression
.curly_expression
and_immediate_brace
rule to scanner (for macro DSLs).interpolation_expression
in more places.scoped_identifier
withfield_expression
in function names. Function names already allow interpolations, so allowing more primary expressions isn't that bad. (e.g.function $M.$f(x) end
).Juxtapositions
coefficient_expression
tojuxtaposition_expression
._primary_expression
in RHS ofjuxtaposition_expression
.tuples and function arguments
call_expression
in parameter list (for Gen.jl).Assignments
let_binding
in terms ofnamed_field
.return_statement
.string_interpolation
.parenthesized_expression
.quote_expression
in assignments' LHS..=
ascompound_assignment_expression
, notassignment
.typed_parameter
infor_binding
._declaration
inmacro_argument_list
.Tests
This PR has two goals:
While it doesn't stand out, one of the most important changes is the extension of valid juxtapositions. tree-sitter has very poor support for explicit whitespace handling, so like in other whitespace sensitive cases, this is a best-effort approximation. It also results in a much more bloated
src/parser.c
.