UNPKG

@secam/pgsql-ast-parser

Version:

Fork of pgsql-ast-parser Simple Postgres SQL parser/modifier for pg-mem

27 lines (24 loc) 618 B
import {compile} from 'moo'; // build lexer export const lexer = compile({ valueString: { match: /"(?:\\["\\]|[^\n"\\])*"/, value: x => JSON.parse(x), type: x => 'value', }, valueRaw: { match: /[^\s,\{\}"](?:[^,\{\}"]*[^\s,\{\}"])?/, type: () => 'value', }, comma: ',', space: { match: /[\s\t\n\v\f\r]+/, lineBreaks: true, }, start_list: '{', end_list: '}', }); lexer.next = (next => () => { let tok; while ((tok = next.call(lexer)) && (tok.type === 'space')) { } return tok; })(lexer.next); export const lexerAny: any = lexer;