86 val attrs_of_displayarea : displayarea -> XML.attributes |
80 val attrs_of_displayarea : displayarea -> XML.attributes |
87 val attrs_of_fatality : fatality -> XML.attributes |
81 val attrs_of_fatality : fatality -> XML.attributes |
88 val attrs_of_location : location -> XML.attributes |
82 val attrs_of_location : location -> XML.attributes |
89 val location_of_attrs : XML.attributes -> location (* raises PGIP *) |
83 val location_of_attrs : XML.attributes -> location (* raises PGIP *) |
90 |
84 |
91 val haspref : preference -> XML.tree |
|
92 |
|
93 val pgipurl_of_url : Url.T -> pgipurl (* raises PGIP *) |
85 val pgipurl_of_url : Url.T -> pgipurl (* raises PGIP *) |
94 val pgipurl_of_string : string -> pgipurl (* raises PGIP *) |
86 val pgipurl_of_string : string -> pgipurl (* raises PGIP *) |
95 val pgipurl_of_path : Path.T -> pgipurl |
87 val pgipurl_of_path : Path.T -> pgipurl |
96 val path_of_pgipurl : pgipurl -> Path.T |
88 val path_of_pgipurl : pgipurl -> Path.T |
97 val string_of_pgipurl : pgipurl -> string |
89 val string_of_pgipurl : pgipurl -> string |
98 val attrs_of_pgipurl : pgipurl -> XML.attributes |
90 val attrs_of_pgipurl : pgipurl -> XML.attributes |
99 val pgipurl_of_attrs : XML.attributes -> pgipurl (* raises PGIP *) |
91 val pgipurl_of_attrs : XML.attributes -> pgipurl (* raises PGIP *) |
100 |
92 |
101 (* XML utils, only for PGIP code *) |
93 (* XML utils, only for PGIP code *) |
102 val has_attr : string -> XML.attributes -> bool |
|
103 val attr : string -> string -> XML.attributes |
94 val attr : string -> string -> XML.attributes |
104 val opt_attr : string -> string option -> XML.attributes |
95 val opt_attr : string -> string option -> XML.attributes |
105 val opt_attr_map : ('a -> string) -> string -> 'a option -> XML.attributes |
96 val opt_attr_map : ('a -> string) -> string -> 'a option -> XML.attributes |
106 val get_attr : string -> XML.attributes -> string (* raises PGIP *) |
97 val get_attr : string -> XML.attributes -> string (* raises PGIP *) |
107 val get_attr_opt : string -> XML.attributes -> string option |
98 val get_attr_opt : string -> XML.attributes -> string option |
111 structure PgipTypes : PGIPTYPES_OPNS = |
102 structure PgipTypes : PGIPTYPES_OPNS = |
112 struct |
103 struct |
113 exception PGIP of string |
104 exception PGIP of string |
114 |
105 |
115 (** XML utils **) |
106 (** XML utils **) |
116 |
|
117 fun has_attr attr attrs = Properties.defined attrs attr |
|
118 |
107 |
119 fun get_attr_opt attr attrs = Properties.get attrs attr |
108 fun get_attr_opt attr attrs = Properties.get attrs attr |
120 |
109 |
121 fun get_attr attr attrs = |
110 fun get_attr attr attrs = |
122 (case get_attr_opt attr attrs of |
111 (case get_attr_opt attr attrs of |
430 in |
419 in |
431 {descr=descr, url=url, line=line, column=column, char=char, length=length} |
420 {descr=descr, url=url, line=line, column=column, char=char, length=length} |
432 end |
421 end |
433 end |
422 end |
434 |
423 |
435 (** Preferences **) |
|
436 |
|
437 type preference = { name: string, |
|
438 descr: string option, |
|
439 default: string option, |
|
440 pgiptype: pgiptype } |
|
441 |
|
442 fun haspref ({ name, descr, default, pgiptype}:preference) = |
|
443 XML.Elem (("haspref", |
|
444 attr "name" name @ |
|
445 opt_attr "descr" descr @ |
|
446 opt_attr "default" default), |
|
447 [pgiptype_to_xml pgiptype]) |
|
448 |
|
449 end |
424 end |
450 |
425 |