let ALPHA = ['A'-'Z' 'a'-'z']
let NUM = ['0'-'9']
let IDEN = ALPHA (NUM | ALPHA)*
-let QSTR = [^ '"\']*
+let QSTR = [^ '"' '\\']+
-
-rule string_token = parse
+rule comm_token = parse
+ | "*)" { query_token lexbuf }
+ | [^ '*']* { comm_token lexbuf }
+and string_token = parse
| '"' { DQ }
- | '\' . { STR (Lexing.lexeme lexbuf) }
- | QSTR { STR (String.sub 1 1 (Lexing.lexeme lexbuf)) }
+ | '\\' _ { STR (String.sub (Lexing.lexeme lexbuf) 1 1) }
+ | QSTR { STR (Lexing.lexeme lexbuf) }
| eof { EOF }
-and main_token = parse
- | SPC { main_token lexbuf }
+and query_token = parse
+ | "(*" { comm_token lexbuf }
+ | SPC { query_token lexbuf }
+ | '"' { STR (qstr string_token lexbuf) }
| '(' { LP }
| ')' { RP }
+ | '{' { LC }
+ | '}' { RC }
| '@' { AT }
| '%' { PC }
| '$' { DL }
| '.' { FS }
- | '"' { STR (qstr string_token lexbuf }
+ | ',' { CM }
+ | '/' { SL }
| "and" { AND }
| "attr" { ATTR }
| "attribute" { ATTRIB }
+ | "be" { BE }
| "diff" { DIFF }
| "eq" { EQ }
+ | "ex" { EX }
| "false" { FALSE }
| "fun" { FUN }
| "in" { IN }
| "intersect" { INTER }
+ | "let" { LET }
+ | "meet" { MEET }
| "not" { NOT }
| "or" { OR }
| "pattern" { PAT }
| "where" { WHERE }
| IDEN { ID (Lexing.lexeme lexbuf) }
| eof { EOF }
-
+and result_token = parse
+ | SPC { result_token lexbuf }
+ | '"' { STR (qstr string_token lexbuf) }
+ | '{' { LC }
+ | '}' { RC }
+ | ',' { CM }
+ | ';' { SC }
+ | '=' { IS }
+ | "attr" { ATTR }
+ | eof { EOF }