Avatar
omochimetaru 9/7/2017 7:37 AM
// comment import Foundation class Cat { var name: String = "mike" }
7:37 AM
[0] process type: SourceFileSyntax [1] process type: SyntaxCollection<DeclSyntax> [2] process type: UnknownDeclSyntax [3] process type: TokenSyntax text: import leading: Trivia(pieces: [// comment, ]) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: Foundation leading: Trivia(pieces: []) trailing: Trivia(pieces: []) [2] process type: UnknownDeclSyntax [3] process type: TokenSyntax text: class leading: Trivia(pieces: [ ]) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: Cat leading: Trivia(pieces: []) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: { leading: Trivia(pieces: []) trailing: Trivia(pieces: []) [3] process type: TokenSyntax text: var leading: Trivia(pieces: [ , ]) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: name leading: Trivia(pieces: []) trailing: Trivia(pieces: []) [3] process type: TokenSyntax text: : leading: Trivia(pieces: []) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: String leading: Trivia(pieces: []) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: = leading: Trivia(pieces: []) trailing: Trivia(pieces: [ ]) [3] process type: TokenSyntax text: "mike" leading: Trivia(pieces: []) trailing: Trivia(pieces: []) [3] process type: TokenSyntax text: } leading: Trivia(pieces: [ ]) trailing: Trivia(pieces: []) [1] process type: TokenSyntax text: leading: Trivia(pieces: [ ]) trailing: Trivia(pieces: [])
7:38 AM
トークンに対して leadingTrivia と trailingTrivia として、コメントとかスペースとか、意味のない系の文字列がついてくる
7:39 AM
TriviaはTriviaPieceの配列で、TriviaPieceは 空白とか行コメントとかブロックコメントみたいな単位で型付けされてる(enum)
7:39 AM
使いやすそうな雰囲気