A work-in-progress SQL parser written in TypeScript
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

token.ts 737B

123456789101112131415161718192021222324252627282930313233343536
  1. export enum TokenKind {
  2. AND = "AND",
  3. AS = "AS",
  4. BACKTICK = "BACKTICK",
  5. COMMA = "COMMA",
  6. DOT = "DOT",
  7. EOF = "EOF",
  8. EQUALS = "EQUALS",
  9. FROM = "FROM",
  10. IDENTIFIER = "IDENTIFIER",
  11. MINUS = "MINUS",
  12. NUMBER = "NUMBER",
  13. OR = "OR",
  14. PLUS = "PLUS",
  15. SELECT = "SELECT",
  16. SEMICOLON = "SEMICOLON",
  17. SLASH = "SLASH",
  18. STAR = "STAR",
  19. WHERE = "WHERE",
  20. }
  21. export default class Token {
  22. public kind: TokenKind;
  23. public value: string | null;
  24. public line: number;
  25. constructor(kind: TokenKind, value: string | null, line: number) {
  26. this.kind = kind;
  27. this.value = value;
  28. this.line = line;
  29. }
  30. public repr(): string {
  31. return `{ kind: ${this.kind}${this.value ? `, value: ${this.value} }` : " }"}`;
  32. }
  33. }