We are using gqlparser for parsing GraphQL schema.
Lexer in gqlparser drops all the comments when it returns the ast. Since we are using comments to enable/disable lint rules
we are using a slightly modified (only change being not dropping the comments) lexer from gqlparser.
If in future gqlparser supports this functionality or there is another lexer which can give us access to comments in schema,
we would remove this copied code.
ReadToken gets the next token from the source starting at the given position.
This skips over whitespace and comments until it finds the next lexable
token, then lexes punctuators immediately or calls the appropriate helper
function for more complicated tokens.
type Token struct {
Kind Type// The token type. Value string// The literal value consumed. Pos ast.Position// The file and line this token was read from}
Kind represents a type of token. The types are predefined as constants.
const (
Invalid Type = iota EOF
Bang
Dollar
Amp
ParenL
ParenR
Spread
Colon
Equals
At
BracketL
BracketR
BraceL
BraceR
Pipe
Name
Int
Float
String
BlockString
Comment
)