z_mirror/luapls
git clone https://git.raiguard.me/z_mirror/luapls
5c64afc
main
1package ast 2 3import ( 4"github.com/raiguard/luapls/lua/token" 5) 6 7type Node interface { 8Pos () token.Pos 9End () token.Pos 10String ()string 11GetLeadingTrivia () []token.Token 12GetSemanticChildren () []Node 13} 14 15func Range (n Node ) token.Range { 16return token.Range {Start :n .Pos (),End :n .End ()} 17} 18 19type Unit struct { 20LeadingTrivia []token.Token 21Token token.Token 22TrailingTrivia []token.Token // Comments and whitespace up to the next newline 23} 24 25func (u * Unit )Type () token.TokenType { 26return u .Token .Type 27} 28 29func (u * Unit )Pos () token.Pos { 30return u .Token .Pos 31} 32 33func (u * Unit )End () token.Pos { 34return u .Token .End () 35} 36 37func (u * Unit )Range () token.Range { 38return token.Range {Start :u .Pos (),End :u .End ()} 39} 40 41func (u * Unit )String ()string { 42return u .Token .Literal 43} 44 45type Block = Punctuated [Statement ] 46 47type Invalid struct { 48Position token.Pos 49} 50 51func (i * Invalid )expressionNode () {} 52func (i * Invalid )statementNode () {} 53func (i * Invalid )Pos () token.Pos { 54return i .Position 55} 56func (i * Invalid )End () token.Pos { 57return i .Position 58} 59 60// A Leaf node has no children and is interactable in the editor. 61type LeafNode interface { 62leaf () 63}