tree-sitter-julia icon indicating copy to clipboard operation
tree-sitter-julia copied to clipboard

Add true, false as literals

Open ChrHorn opened this issue 2 years ago • 3 comments

This PR adds (nothing), (missing), (true), (false) literals.

Makes querying these a bit easier.

Edit: only add (true) and (false), see discussion below

ChrHorn avatar Aug 05 '22 15:08 ChrHorn

When I was revising the other literals I left these out because of the following:

julia> true === :true
true

julia> false === :false
true

julia> nothing === :nothing
false

julia> missing === :missing
false

The booleans behave like numbers or any other literal, but nothing and missing are regular values (aliases for Nothing() and Missing() respectively).

savq avatar Aug 31 '22 21:08 savq

Yes, that's a good argument, undef also belongs to the same category. The (new) Julia parser also treats these as identifiers:

julia> parseall(GreenNode, "true; false; nothing; missing")
     1:29     │[toplevel]
     1:29     │  [toplevel]
     1:4      │    true                 ✔
     5:5      │    ;
     6:6      │    Whitespace
     7:11     │    false                ✔
    12:12     │    ;
    13:13     │    Whitespace
    14:20     │    Identifier           ✔
    21:21     │    ;
    22:22     │    Whitespace
    23:29     │    Identifier           ✔

Best to keep this PR to true and false.

ChrHorn avatar Sep 01 '22 07:09 ChrHorn

updated and regenerated

ChrHorn avatar Sep 01 '22 07:09 ChrHorn