From 57a47d11437c168d5ee1c6024ae7a48df8a302ba Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Tue, 10 Sep 2002 17:48:27 +0000 Subject: [PATCH] a small correction to mathQL.ml --- helm/ocaml/mathql/mQueryTLexer.mll | 82 ++++++++++++++--------------- helm/ocaml/mathql/mQueryTParser.mly | 58 ++++++-------------- helm/ocaml/mathql/mathQL.ml | 2 +- 3 files changed, 55 insertions(+), 87 deletions(-) diff --git a/helm/ocaml/mathql/mQueryTLexer.mll b/helm/ocaml/mathql/mQueryTLexer.mll index 0075f3ac1..ca24965b1 100644 --- a/helm/ocaml/mathql/mQueryTLexer.mll +++ b/helm/ocaml/mathql/mQueryTLexer.mll @@ -41,48 +41,44 @@ let SPC = [' ' '\t' '\n']+ let ALPHA = ['A'-'Z' 'a'-'z'] let NUM = ['0'-'9'] let IDEN = ALPHA (NUM | ALPHA)* -let DQ = '"' -let SQ = ''' -let QSTR = [^ ''']* -let USTR = [^ '"' ':' '/' '#' '?' '*']+ +let QSTR = [^ '"\']* -rule rtoken = parse - | DQ { DQT } - | ":/" { PROT } - | "/" { SLASH } - | "#1" { FRAG } - | "?" { QUEST } - | "**" { SSTAR } - | "*" { STAR } - | USTR { STR (Lexing.lexeme lexbuf) } -and stoken = parse - | SQ { SQT } - | QSTR { STR (Lexing.lexeme lexbuf) } -and qtoken = parse - | SPC { qtoken lexbuf } - | '(' { LPR } - | ')' { RPR } - | '$' { DLR } - | SQ { STR (qstr stoken lexbuf) } - | DQ { REF (ref rtoken lexbuf) } - | "name" { NAME } - | "mainconclusion" { MCONCL } - | "conclusion" { CONCL } - | "true" { TRUE } - | "false" { FALSE } - | "and" { AND } - | "or" { OR } - | "not" { NOT } - | "is" { IS } - | "select" { SELECT } - | "in" { IN } - | "where" { WHERE } - | "use" { USE } - | "position" { POS } - | "usedby" { USEDBY } - | "pattern" { PATT } - | "union" { UNION } - | "intersect" { INTER } - | IDEN { ID (Lexing.lexeme lexbuf) } - | eof { EOF } + +rule string_token = parse + | '"' { DQ } + | '\' . { STR (Lexing.lexeme lexbuf) } + | QSTR { STR (String.sub 1 1 (Lexing.lexeme lexbuf)) } + | eof { EOF } +and main_token = parse + | SPC { main_token lexbuf } + | '(' { LP } + | ')' { RP } + | '@' { AT } + | '%' { PC } + | '$' { DL } + | '.' { FS } + | '"' { STR (qstr string_token lexbuf } + | "and" { AND } + | "attr" { ATTR } + | "attribute" { ATTRIB } + | "diff" { DIFF } + | "eq" { EQ } + | "false" { FALSE } + | "fun" { FUN } + | "in" { IN } + | "intersect" { INTER } + | "not" { NOT } + | "or" { OR } + | "pattern" { PAT } + | "ref" { REF } + | "refof" { REFOF } + | "relation" { REL } + | "select" { SELECT } + | "sub" { SUB } + | "super" { SUPER } + | "true" { TRUE } + | "union" { UNION } + | "where" { WHERE } + | IDEN { ID (Lexing.lexeme lexbuf) } + | eof { EOF } diff --git a/helm/ocaml/mathql/mQueryTParser.mly b/helm/ocaml/mathql/mQueryTParser.mly index 9bfcd4e0c..7f1c6e91b 100644 --- a/helm/ocaml/mathql/mQueryTParser.mly +++ b/helm/ocaml/mathql/mQueryTParser.mly @@ -34,61 +34,33 @@ /******************************************************************************/ %{ - open MathQL %} %token ID STR - %token REF - %token LPR RPR DLR SQT DQT EOF PROT SLASH FRAG QUEST STAR SSTAR - %token NAME - %token MCONCL CONCL - %token TRUE FALSE AND OR NOT IS - %token SELECT IN WHERE USE POS USEDBY PATT UNION INTER + %token LC RC CM SC LP RP AT PC DL FS DQ EOF + %token AND ATTR ATTRIB DIFF EQ FALSE FUN IN INTER NOT OR PAT REF REFOF + %token REL SELECT SUB SUPER TRUE UNION WHERE + %left DIFF %left OR UNION %left AND INTER %nonassoc NOT %start qstr ref query - %type qstr - %type ref - %type query + %type qstr + %type query %% - prot: - | STR { Some $1 } - | STAR { None } - ; - body: - | { [] } - | SLASH body { MQBD :: $2 } - | QUEST body { MQBQ :: $2 } - | SSTAR body { MQBSS :: $2 } - | STAR body { MQBS :: $2 } - | STR body { MQBC $1 :: $2 } - frag: - | { [] } - | SLASH SSTAR frag { MQFSS :: $3 } - | SLASH STAR frag { MQFS :: $3 } - | SLASH STR frag { try let i = int_of_string $2 in - if i < 1 then raise Parsing.Parse_error; - MQFC i :: $3 - with e -> raise Parsing.Parse_error - } - ; - ref: - | prot PROT body DQT { ($1, $3, []) } - | prot PROT body FRAG frag DQT { ($1, $3, $5) } - ; qstr: - | STR SQT { $1 } + | QT { "" } + | STR qstr { $1 @ $2 } + ; + svar: + | PC ID { $2 } ; rvar: - | ID { $1 } + | AT ID { $2 } ; - svar: - | DLR ID { $2 } + vvar: + | DL ID { $2 } ; - func: - | NAME { MQName } - ; - str: + val: | MCONCL { MQMConclusion } | CONCL { MQConclusion } | STR { MQCons $1 } diff --git a/helm/ocaml/mathql/mathQL.ml b/helm/ocaml/mathql/mathQL.ml index ee10c6acf..e37b03d7c 100644 --- a/helm/ocaml/mathql/mathQL.ml +++ b/helm/ocaml/mathql/mathQL.ml @@ -47,7 +47,7 @@ type refine_op = Exact | Sub | Super -type attr_list = string list +type attr_list = vvar list type set_exp = SVar of svar | RVar of rvar -- 2.39.2