Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"alias:" production emitted in many places #20

Open
seh opened this issue Aug 14, 2023 · 2 comments
Open

"alias:" production emitted in many places #20

seh opened this issue Aug 14, 2023 · 2 comments

Comments

@seh
Copy link

seh commented Aug 14, 2023

I noticed that when I inspect the s-expression view of tree-sitter parse, before a top-level struct and before each field in a struct I see the tag "alias". For the following input file, I see the output that follows:

{
   id: 1
}
alias: 
 (struct_lit {
  alias: 
   (field
    (label (identifier))
    :
    (value (number)))
  })

What do the "alias:" lines mean there on the first and third lines? Is that tree-sitter indicating that an optional identifier and following = character are acceptable there but absent?

@eonpatapon
Copy link
Owner

Not sure why you get this output, do you use tip, which version of tree-sitter ?

alias: should be seen when some cue alias is defined like:

✦ tree-sitter --version
tree-sitter 0.20.8

✦ cat test.cue 
{
	id: 1
	FirstAlias=b: 2
}

[SecondAlias=string]: int


✦ tree-sitter parse test.cue 

(source_file [0, 0] - [6, 0]
  (struct_lit [0, 0] - [3, 1]
    (field [1, 1] - [1, 6]
      (label [1, 1] - [1, 3]
        (identifier [1, 1] - [1, 3]))
      (value [1, 5] - [1, 6]
        (int_lit [1, 5] - [1, 6])))
    (field [2, 1] - [2, 16]
      (label [2, 1] - [2, 13]
        alias: (identifier [2, 1] - [2, 11])
        (identifier [2, 12] - [2, 13]))
      (value [2, 15] - [2, 16]
        (int_lit [2, 15] - [2, 16]))))
  (field [5, 0] - [5, 25]
    (label [5, 0] - [5, 20]
      (optional [5, 1] - [5, 19]
        alias: (identifier [5, 1] - [5, 12])
        (string_type [5, 13] - [5, 19])))
    (value [5, 22] - [5, 25]
      (int_type [5, 22] - [5, 25]))))

@seh
Copy link
Author

seh commented Aug 17, 2023

Not sure why you get this output, do you use tip, which version of tree-sitter?

I think it was the Emacs treesit-auto package that took care of downloading and building the library, so it probably pulled the head revision here.

I see the output via Emacs's treesit-explore-mode. I had installed tree-sitter-cli via npm, presumably at version 0.20.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants