X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fwww%2Flambdadelta%2Fbin%2Fxhtbl%2FtextParser.mly;h=9072c2b23ddf96932583b797c8125945bf4f9c9a;hb=57ae1762497a5f3ea75740e2908e04adb8642cc2;hp=3864bc53c05ec6087b2a0c2fdc1da50c03d39a4b;hpb=cb0d4e730bd6ec9bed1018be37748120f740f0a9;p=helm.git diff --git a/helm/www/lambdadelta/bin/xhtbl/textParser.mly b/helm/www/lambdadelta/bin/xhtbl/textParser.mly index 3864bc53c..9072c2b23 100644 --- a/helm/www/lambdadelta/bin/xhtbl/textParser.mly +++ b/helm/www/lambdadelta/bin/xhtbl/textParser.mly @@ -7,18 +7,23 @@ 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 SPACE NAME TABLE CSS SR OC CC OB CB PS OP CP AT EOF +%token SPACE NAME TABLE CSS URI EXT SR OC CC OB CB PS CF OP CP AT EOF %start script -%type <(string * string) list * (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 %% @@ -32,13 +37,17 @@ spaces: ; text: - | TEXT { T.Plain $1 } - | AT OP TEXT TEXT CP { T.Link ($3, $4) } + | 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: @@ -52,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: @@ -87,17 +106,35 @@ ranges: | range ranges { $1 :: $2 } ; -atom: - | CSS TEXT ranges { mk_atom $2 $3 } +catom: + | CSS TEXT ranges { mk_css_atom $2 $3 } +; + +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 } ; -atoms: - | { [] } - | atom atoms { $1 @ $2 } +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: