]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/mQueryTLexer.mll
patched and some funtions added
[helm.git] / helm / ocaml / mathql_interpreter / mQueryTLexer.mll
index 4be6ba298e412fb5b89c0e32af48079fe2c0d2fc..00fc9dc68701bc58cdea3250d362b8596d230dbd 100644 (file)
@@ -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,15 @@ 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) } 
    | "add"       { out "ADD"   ; ADD    }
    | "align"     { out "ALIGN" ; ALIGN  }
    | "allbut"    { out "BUT"   ; BUT    }
@@ -104,8 +111,11 @@ 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 }
@@ -118,8 +128,6 @@ and query_token = parse
    | "union"     { out "UNION" ; UNION  }
    | "where"     { out "WHERE" ; WHERE  }
    | "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  }
@@ -132,14 +140,18 @@ and query_token = parse
    | "\\/"       { 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  }