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 779B

1234567891011121314151617181920212223242526272829303132333435363738
  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. LPAREN = "LPAREN",
  12. MINUS = "MINUS",
  13. NUMBER = "NUMBER",
  14. OR = "OR",
  15. PLUS = "PLUS",
  16. RPAREN = "RPAREN",
  17. SELECT = "SELECT",
  18. SEMICOLON = "SEMICOLON",
  19. SLASH = "SLASH",
  20. STAR = "STAR",
  21. WHERE = "WHERE",
  22. }
  23. export default class Token {
  24. public kind: TokenKind;
  25. public value: string | null;
  26. public line: number;
  27. constructor(kind: TokenKind, value: string | null, line: number) {
  28. this.kind = kind;
  29. this.value = value;
  30. this.line = line;
  31. }
  32. public repr(): string {
  33. return `{ kind: ${this.kind}${this.value ? `, value: ${this.value} }` : " }"}`;
  34. }
  35. }