1 module graphql.tokenmodule; 2 3 import graphql.visitor; 4 5 enum TokenType { 6 undefined, 7 exclamation, 8 dollar, 9 lparen, 10 rparen, 11 dots, 12 colon, 13 equal, 14 at, 15 lbrack, 16 rbrack, 17 lcurly, 18 rcurly, 19 pipe, 20 name, 21 intValue, 22 floatValue, 23 stringValue, 24 query, 25 mutation, 26 subscription, 27 fragment, 28 on_, 29 alias_, 30 true_, 31 false_, 32 null_, 33 comment, 34 comma, 35 union_, 36 type, 37 typename, 38 skip, 39 include_, 40 input, 41 scalar, 42 schema, 43 schema__, 44 directive, 45 enum_, 46 interface_, 47 implements, 48 extend, 49 } 50 51 struct Token { 52 @safe: 53 size_t line; 54 size_t column; 55 string value; 56 57 TokenType type; 58 59 this(TokenType type) { 60 this.type = type; 61 } 62 63 this(TokenType type, size_t line, size_t column) { 64 this.type = type; 65 this.line = line; 66 this.column = column; 67 } 68 69 this(TokenType type, string value) { 70 this(type); 71 this.value = value; 72 } 73 74 this(TokenType type, string value, size_t line, size_t column) { 75 this(type, line, column); 76 this.value = value; 77 } 78 79 void visit(ConstVisitor vis) { 80 } 81 82 void visit(ConstVisitor vis) const { 83 } 84 85 void visit(Visitor vis) { 86 } 87 88 void visit(Visitor vis) const { 89 } 90 91 string toString() const { 92 import std.format : format; 93 return format("Token(%s,%s,%s,%s)", this.line, this.column, this.type, 94 this.value); 95 } 96 } 97