X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fwww%2Flambdadelta%2Fbin%2Fxhtbl%2FtextParser.mly;h=9072c2b23ddf96932583b797c8125945bf4f9c9a;hb=57ae1762497a5f3ea75740e2908e04adb8642cc2;hp=333d3421f2fa27a3f0c89db7f395266ebe793ee0;hpb=2a5e0b799cd6aae5d920c67a5ddc9d9888cf7e80;p=helm.git diff --git a/helm/www/lambdadelta/bin/xhtbl/textParser.mly b/helm/www/lambdadelta/bin/xhtbl/textParser.mly index 333d3421f..9072c2b23 100644 --- a/helm/www/lambdadelta/bin/xhtbl/textParser.mly +++ b/helm/www/lambdadelta/bin/xhtbl/textParser.mly @@ -7,27 +7,47 @@ module T = Table let split s = S.split (S.regexp "[ \r\n\t]+") s -let mk_atom s rs = - let map c (b, (x1, x2)) = c, b, x1, x2 in - L.map (map (split s)) rs +let mk_css_atom s rs = + let cs = split s in + let map (b, (x1, x2)) = cs, b, x1, x2 in + L.map map rs + +let mk_string_atom s rs = + let map (b, (x1, x2)) = s, b, x1, x2 in + L.map map rs %} %token NUM %token TEXT -%token NAME TABLE CSS SR OC CC OB CB PS EOF +%token SPACE NAME TABLE CSS URI EXT SR OC CC OB CB PS CF OP CP AT EOF %start script -%type <(string * Table.table * Css.atoms) list> script +%type <(string * string) list * (string * Table.table * Table.css Attr.atoms * Table.uri Attr.atoms * Table.ext Attr.atoms) list> script %% +space: + | SPACE TEXT TEXT { $2, $3 } +; + +spaces: + | { [] } + | space spaces { $1 :: $2 } +; + text: - | TEXT { $1 } + | TEXT { T.Plain $1 } + | AT OP TEXT TEXT CP { T.Link (true, $3, $4) } + | AT AT OP TEXT TEXT CP { T.Link (false, $4, $5) } + | AT TEXT { T.Link (true, $2, $2) } + | AT AT TEXT { T.Link (false, $3, $3) } +; texts: - | text { [$1] } - | text PS texts { $1 :: $3 } + | text { [$1] } + | text PS texts { $1 :: T.Plain " " :: $3 } + | text CF texts { $1 :: $3 } ; key: @@ -41,10 +61,20 @@ css: | CSS TEXT { split $2 } ; +uri: + | { "" } + | URI TEXT { $2 } +; + +ext: + | { "" } + | EXT TEXT { $2 } +; + table: - | css key { T.mk_key $2 $1 } - | css OC tables CC { T.mk_line false $3 $1 } - | css OB tables CB { T.mk_line true $3 $1 } + | css uri ext name key { T.mk_key $5 $1 $2 $3 $4 } + | css uri ext OC tables CC { T.mk_line false $5 $1 $2 $3 "" } + | css uri ext OB tables CB { T.mk_line true $5 $1 $2 $3 "" } ; tables: @@ -76,20 +106,42 @@ ranges: | range ranges { $1 :: $2 } ; -atom: - | CSS TEXT ranges { mk_atom $2 $3 } +catom: + | CSS TEXT ranges { mk_css_atom $2 $3 } ; -atoms: - | { [] } - | atom atoms { $1 @ $2 } +catoms: + | { [] } + | catom catoms { $1 @ $2 } +; + +uatom: + | URI TEXT ranges { mk_string_atom $2 $3 } +; + +uatoms: + | { [] } + | uatom uatoms { $1 @ $2 } +; + +xatom: + | EXT TEXT ranges { mk_string_atom $2 $3 } +; + +xatoms: + | { [] } + | xatom xatoms { $1 @ $2 } ; directive: - | name TABLE table atoms { $1, $3, $4 } + | name TABLE table catoms uatoms xatoms { $1, $3, $4, $5, $6 } +; + +directives: + | { [] } + | directive directives { $1 :: $2 } ; script: - | EOF { [] } - | directive script { $1 :: $2 } + | spaces directives EOF { $1, $2 } ;