X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Ftex_cic_textual_parser%2FtexCicTextualParser.mly;h=500565823d20a328166fd06dda7e2222d4860777;hb=3f88b5fffc17ecc8b3cb1645f9be846e740c8a3a;hp=e26145e2855ba815dd03c1814750642ce40779aa;hpb=bac72fcaa876137ab7a5630e0c1badc2a627dce8;p=helm.git diff --git a/helm/ocaml/tex_cic_textual_parser/texCicTextualParser.mly b/helm/ocaml/tex_cic_textual_parser/texCicTextualParser.mly index e26145e28..500565823 100644 --- a/helm/ocaml/tex_cic_textual_parser/texCicTextualParser.mly +++ b/helm/ocaml/tex_cic_textual_parser/texCicTextualParser.mly @@ -151,6 +151,7 @@ %token ID %token META %token NUM +%token RNUM %token CONURI %token VARURI %token INDTYURI @@ -158,11 +159,12 @@ %token LPAREN RPAREN PROD LAMBDA COLON DOT SET PROP TYPE CAST IMPLICIT NONE %token LETIN FIX COFIX SEMICOLON LCURLY RCURLY CASE ARROW LBRACKET RBRACKET EOF %token DOLLAR -%token PLUS MINUS TIMES EQ +%token RPLUS RMINUS RTIMES RDIV +%token PLUS MINUS TIMES EQT EQ NEQT %right ARROW -%right EQ -%right PLUS MINUS -%right TIMES +%nonassoc EQ EQT NEQT +%left PLUS MINUS RPLUS RMINUS +%left TIMES RTIMES RDIV %start main %type Cic.term)> main %% @@ -178,7 +180,30 @@ main: */ ; expr2: - NUM + | RNUM + { [], function interp -> + let rec cic_real_of_real = + function + 0 -> + Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/R0.con",[]) + | 1 -> + Cic.Const + (UriManager.uri_of_string "cic:/Coq/Reals/Rdefinitions/R1.con",[]) + | n -> + Cic.Appl + [ Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/Rplus.con",[]) ; + Cic.Const (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/R1.con",[]); + cic_real_of_real (n - 1) + ] + in + cic_real_of_real $1 + } + | NUM { [], function interp -> let rec cic_int_of_int = function @@ -196,6 +221,58 @@ expr2: in cic_int_of_int $1 } + | expr2 RPLUS expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom = union dom1 dom2 in + dom, function interp -> + Cic.Appl + [Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/Rplus.con",[]) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ] + } + | expr2 RMINUS expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom = union dom1 dom2 in + dom, function interp -> + Cic.Appl + [Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/Rminus.con",[]) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ] + } + | expr2 RTIMES expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom = union dom1 dom2 in + dom, function interp -> + Cic.Appl + [Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/Rmult.con",[]) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ] + } + | expr2 RDIV expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom = union dom1 dom2 in + dom, function interp -> + Cic.Appl + [Cic.Const + (UriManager.uri_of_string + "cic:/Coq/Reals/Rdefinitions/Rdiv.con",[]) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ] + } | expr2 PLUS expr2 { let dom1,mk_expr1 = $1 in let dom2,mk_expr2 = $3 in @@ -232,6 +309,36 @@ expr2: (mk_expr2 interp) ] } + | expr2 EQT expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom3,mk_expr3 = mk_implicit () in + let dom = union dom1 (union dom2 dom3) in + dom, function interp -> + Cic.Appl + [Cic.MutInd + (UriManager.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind",0,[]) ; + (mk_expr3 interp) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ] + } + | expr2 NEQT expr2 + { let dom1,mk_expr1 = $1 in + let dom2,mk_expr2 = $3 in + let dom3,mk_expr3 = mk_implicit () in + let dom = union dom1 (union dom2 dom3) in + dom, function interp -> + Cic.Appl [ + Cic.Const (UriManager.uri_of_string "cic:/Coq/Init/Logic/not.con",[]); + Cic.Appl + [Cic.MutInd + (UriManager.uri_of_string "cic:/Coq/Init/Logic_Type/eqT.ind",0,[]) ; + (mk_expr3 interp) ; + (mk_expr1 interp) ; + (mk_expr2 interp) + ]] + } | expr2 EQ expr2 { let dom1,mk_expr1 = $1 in let dom2,mk_expr2 = $3 in