tree-sitter / tree-sitter-julia

Julia grammar for Tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement an `immediate_identifier` rule

savq opened this issue · comments

Many of the context-sensitive rules of the Julia grammar need to know whether a rule starts with an identifier.

For example, juxtaposition (implicit multiplication) work if the LHS is a number or if the RHS starts with an identifier:

2x         # Ok
2(x + 1)   # Ok. LHS is number
f()g()     # Ok. RHS starts with identifier
(n - 1) n  # Err. there's a space between the parenthesis and `n`
f(x).+(y)  # Ok. Not a juxtaposition of function calls, but a binary expression

Another example are quotations:

:foo  # Ok
: bar # Err

Currently, the scanner implements rules to check if there's an immediate opening brace/bracket/parenthesis. There's should be an similar rule for identifers and operators.

This requires being able to check unicode categories in the scanner.