X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=components%2Fbinaries%2Ftranscript%2Fv8Parser.mly;h=06d4d908ba2fd7d9c49e8794e4d413a222279dff;hb=62e3a3ce3ac21ab25074ad2af1883a4b0cbc62be;hp=9529bfb62529024897bd2f71c668727e4d9b436c;hpb=0dfad591e92a2c1174313ed7be80da0084b618b3;p=helm.git diff --git a/components/binaries/transcript/v8Parser.mly b/components/binaries/transcript/v8Parser.mly index 9529bfb62..06d4d908b 100644 --- a/components/binaries/transcript/v8Parser.mly +++ b/components/binaries/transcript/v8Parser.mly @@ -28,10 +28,14 @@ let out t s = () (* prerr_endline ("-- " ^ t ^ " " ^ s) *) + let trim = HExtlib.trim_blanks + + let hd = List.hd + let cat x = String.concat " " x let mk_vars idents = - let map ident = T.Inline (T.Var, ident) in + let map ident = T.Inline (T.Var, trim ident) in List.map map idents let strip2 s = @@ -40,7 +44,11 @@ let strip1 s = String.sub s 1 (String.length s - 1) - let hd = List.hd + let coercion str = + [T.Coercion (false, str); T.Coercion (true, str)] + + let notation str = + [T.Notation (false, str); T.Notation (true, str)] %} %token SPC STR IDENT INT EXTRA AC OP CP OC CC OQ CQ DEF FS COE CN SC %token LET IN TH PROOF QED VAR IND SEC REQ XP IP SET NOT LOAD ID COERC @@ -89,7 +97,6 @@ id: ID spcs { $1 ^ $2 }; coerc: COERC spcs { $1 ^ $2 }; - idents: | ident { [$1] } | ident idents { $1 :: $2 } @@ -187,8 +194,10 @@ | unexport_r spcs unexports_r { fst $1 ^ $2 ^ fst $3, snd $1 @ snd $3 } ; field: - | ident cn unexports_r { $1 ^ $2 ^ fst $3, snd $3 } - | ident coe unexports_r { $1 ^ $2 ^ fst $3, snd $3 @ [T.Coercion $1] } + | ident cn unexports_r + { $1 ^ $2 ^ fst $3, snd $3 } + | ident coe unexports_r + { $1 ^ $2 ^ fst $3, snd $3 @ coercion (trim $1) } ; fields: | field { $1 } @@ -242,47 +251,47 @@ macro_step: | th ident restricts fs proof FS steps qed FS - { out "TH" $2; $7 @ [T.Inline (T.Con, $2)] } + { out "TH" $2; $7 @ [T.Inline (T.Con, trim $2)] } | th ident restricts fs proof restricts FS - { out "TH" $2; [T.Inline (T.Con, $2)] } + { out "TH" $2; [T.Inline (T.Con, trim $2)] } | th ident restricts fs steps qed FS - { out "TH" $2; $5 @ [T.Inline (T.Con, $2)] } + { out "TH" $2; $5 @ [T.Inline (T.Con, trim $2)] } | th ident restricts def restricts FS - { out "TH" $2; [T.Inline (T.Con, $2)] } + { out "TH" $2; [T.Inline (T.Con, trim $2)] } | th ident def restricts FS - { out "TH" $2; [T.Inline (T.Con, $2)] } + { out "TH" $2; [T.Inline (T.Con, trim $2)] } | var idents xres FS - { out "VAR" (cat $2); mk_vars $2 } + { out "VAR" (cat $2); mk_vars $2 } | ind ident unexports FS - { out "IND" $2; snd $3 @ [T.Inline (T.Ind, $2)] } + { out "IND" $2; T.Inline (T.Ind, trim $2) :: snd $3 } | sec unexports FS - { out "UNX" (fst $2); [T.Unexport ($1 ^ fst $2 ^ $3)] } + { out "UNX" (fst $2); [T.Unexport ($1 ^ fst $2 ^ trim $3)] } | req xp ident FS - { out "REQ" $3; [T.Include $3] } + { out "REQ" $3; [T.Include (trim $3)] } | req ip ident FS - { out "REQ" $3; [T.Include $3] } + { out "REQ" $3; [T.Include (trim $3)] } | req ident FS - { out "REQ" $2; [T.Include $2] } + { out "REQ" $2; [T.Include (trim $2)] } | load str FS - { out "REQ" $2; [T.Include (strip2 $2)] } + { out "REQ" $2; [T.Include (strip2 (trim $2))] } | coerc qid spcs cn unexports FS - { out "COERCE" (hd $2); [T.Coercion (hd $2)] } + { out "COERCE" (hd $2); coercion (hd $2) } | id coerc qid spcs cn unexports FS - { out "COERCE" (hd $3); [T.Coercion (hd $3)] } + { out "COERCE" (hd $3); coercion (hd $3) } | th ident error - { out "ERROR" $2; failwith ("macro_step " ^ $2) } + { out "ERROR" $2; failwith ("macro_step " ^ $2) } | ind ident error - { out "ERROR" $2; failwith ("macro_step " ^ $2) } + { out "ERROR" $2; failwith ("macro_step " ^ $2) } | var idents error { let vs = cat $2 in - out "ERROR" vs; failwith ("macro_step " ^ vs) } + out "ERROR" vs; failwith ("macro_step " ^ vs) } ; item: - | comment { [T.Comment $1] } - | macro_step { $1 } - | set unexports FS { [T.Unexport ($1 ^ fst $2 ^ $3)] } - | notation unexports FS { [T.Notation ($1 ^ fst $2 ^ $3)] } - | error { out "ERROR" "item"; failwith "item" } + | OQ verbatims CQ { [T.Comment $2] } + | macro_step { $1 } + | set unexports FS { [T.Unexport ($1 ^ fst $2 ^ trim $3)] } + | notation unexports FS { notation ($1 ^ fst $2 ^ trim $3) } + | error { out "ERROR" "item"; failwith "item" } ; items: | rspcs EOF { [] }