X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2FmQueryTLexer.mll;h=c4abce8e8bb74ba28dac48047fb32d6e203d3d1f;hb=04cc990d9452b85535c5dc93655078d9fb19b14c;hp=4be6ba298e412fb5b89c0e32af48079fe2c0d2fc;hpb=9cbce40d56958c466459b028cf250441ec29c9fe;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/mQueryTLexer.mll b/helm/ocaml/mathql_interpreter/mQueryTLexer.mll index 4be6ba298..c4abce8e8 100644 --- a/helm/ocaml/mathql_interpreter/mQueryTLexer.mll +++ b/helm/ocaml/mathql_interpreter/mQueryTLexer.mll @@ -29,6 +29,8 @@ { open MQueryTParser + let strip s = String.sub s 1 (pred (String.length s)) + let debug = false let out s = if debug then prerr_endline s @@ -39,6 +41,8 @@ let ALPHA = ['A'-'Z' 'a'-'z' '_'] let NUM = ['0'-'9'] let IDEN = ALPHA (NUM | ALPHA)* let QSTR = [^ '"' '\\']+ +let Q = ['\\' '^' '\"'] +let NQ = [^ '\\' '^' '\"'] rule comm_token = parse | "(*" { comm_token lexbuf; comm_token lexbuf } @@ -47,7 +51,8 @@ rule comm_token = parse | [^ '*' '(']* { comm_token lexbuf } and string_token = parse | '"' { DQ } - | '\\' _ { STR (String.sub (Lexing.lexeme lexbuf) 1 1) } + | '\\' Q '^' { STR (String.sub (Lexing.lexeme lexbuf) 1 1) } + | '\\' NQ '^' { STR (Lexing.lexeme lexbuf) } | QSTR { STR (Lexing.lexeme lexbuf) } | eof { EOF } and query_token = parse @@ -61,13 +66,16 @@ and query_token = parse | ']' { out "RB"; RB } | '{' { out "LC"; LC } | '}' { out "RC"; RC } - | '@' { out "AT"; AT } - | '$' { out "DL"; DL } | '.' { out "FS"; FS } | ',' { out "CM"; CM } | ';' { out "SC"; SC } | '/' { out "SL"; SL } | ';' { out "SC"; SC } + | "@" IDEN { let id = Lexing.lexeme lexbuf in + out ("AVAR " ^ id); AVAR (strip id) } + | "$" IDEN { let id = Lexing.lexeme lexbuf in + out ("SVAR " ^ id); SVAR (strip id) } + | ";;" { out ";;" ; SEQ } | "add" { out "ADD" ; ADD } | "align" { out "ALIGN" ; ALIGN } | "allbut" { out "BUT" ; BUT } @@ -85,6 +93,7 @@ and query_token = parse | "false" { out "FALSE" ; FALSE } | "for" { out "FOR" ; FOR } | "from" { out "FROM" ; FROM } + | "gen" { out "GEN" ; GEN } | "if" { out "IF" ; IF } | "in" { out "IN" ; IN } | "inf" { out "INF" ; INF } @@ -104,10 +113,12 @@ and query_token = parse | "of" { out "OF" ; OF } | "or" { out "OR" ; OR } | "pattern" { out "PAT" ; PAT } + | "peek" { out "PEEK" ; PEEK } | "proj" { out "PROJ" ; PROJ } | "property" { out "PROP" ; PROP } + | "read" { out "READ" ; READ } + | "render" { out "RENDER"; RENDER } | "select" { out "SELECT"; SELECT } - | "seq" { out "SEQ" ; SEQ } | "source" { out "SOURCE"; SOURCE } | "stat" { out "STAT" ; STAT } | "sub" { out "SUB" ; SUB } @@ -117,9 +128,8 @@ and query_token = parse | "true" { out "TRUE" ; TRUE } | "union" { out "UNION" ; UNION } | "where" { out "WHERE" ; WHERE } + | "while" { out "WHILE" ; WHILE } | "xor" { out "XOR" ; XOR } - | IDEN { let id = Lexing.lexeme lexbuf in - out ("ID " ^ id); ID id } | eof { out "EOF" ; EOF } | "=" { out "BE" ; BE } | "#" { out "COUNT" ; COUNT } @@ -131,15 +141,18 @@ and query_token = parse | "||" { out "OR" ; OR } | "\\/" { out "UNION" ; UNION } | "/\\" { out "INTER" ; INTER } - | ";;" { out "SEQ" ; SEQ } + | "begin" { out "LP" ; LP } + | "end" { out "RP" ; RP } and result_token = parse | SPC { result_token lexbuf } | "(*" { comm_token lexbuf; result_token lexbuf } - | '"' { STR (qstr string_token lexbuf) } - | '{' { LC } - | '}' { RC } - | ',' { CM } - | ';' { SC } - | '=' { IS } - | "attr" { ATTR } - | eof { EOF } + | '"' { let str = qstr string_token lexbuf in + out ("STR " ^ str); STR str } + | '/' { out "SL" ; SL } + | '{' { out "LC" ; LC } + | '}' { out "RC" ; RC } + | ',' { out "CM" ; CM } + | ';' { out "SC" ; SC } + | '=' { out "BE" ; BE } + | "attr" { out "ATTR"; ATTR } + | eof { out "EOF" ; EOF }