## html-abstract-syntax.pkg
# Compiled by:
#
src/lib/html/html.lib# This file defines the abstract syntax of HTML documents.
# The AST follows the HTML 3.2 Proposed Standard.
package html_abstract_syntax
: (weak) Html_Abstract_Syntax # Html_Abstract_Syntax is from
src/lib/html/html-abstract-syntax.api{
html_version = "3.2 Final";
Pcdata = String;
Cdata = String;
Url = String;
Name = String;
Id = String;
Pixels = Cdata;
fun match sl s
=
{
compare = string::compare_sequences
(\\ (c1, c2) => char::compare (char::to_upper c1, c2); end );
fun eq (REF s')
=
(compare (s, s') == exceptions::EQUAL);
list::find eq sl;
};
# The different types of HTTP methods
#
package http_method {
Method = Ref( String );
get = REF "GET";
put = REF "PUT";
fun to_string (REF s) = s;
from_string = match [get, put];
};
# The different types of INPUT elements
#
package input_type {
Type = Ref( String );
text = REF "TEXT";
password = REF "PASSWORD";
checkbox = REF "CHECKBOX";
radio = REF "RADIO";
submit = REF "SUBMIT";
reset = REF "RESET";
file = REF "FILE";
hidden = REF "HIDDEN";
image = REF "IMAGE";
fun to_string (REF s) = s;
from_string = match [
text, password, checkbox,
radio, submit, reset,
file, hidden, image
];
};
# Alignment attributes for IMG, APPLET and INPUT elements
#
package ialign {
Align = Ref( String );
top = REF "TOP";
middle = REF "MIDDLE";
bottom = REF "BOTTOM";
left = REF "LEFT";
right = REF "RIGHT";
fun to_string (REF s) = s;
from_string = match [top, middle, bottom, left, right];
};
package halign {
Align = Ref( String );
left = REF "LEFT";
center = REF "CENTER";
right = REF "RIGHT";
fun to_string (REF s) = s;
from_string = match [left, center, right];
};
package cell_valign {
Align = Ref( String );
top = REF "TOP";
middle = REF "MIDDLE";
bottom = REF "BOTTOM";
baseline = REF "BASELINE";
fun to_string (REF s) = s;
from_string = match [top, middle, bottom, baseline];
};
package caption_align {
Align = Ref( String );
top = REF "TOP";
bottom = REF "BOTTOM";
left = REF "LEFT";
right = REF "RIGHT";
fun to_string (REF s) = s;
from_string = match [top, bottom, left, right];
};
package ulstyle {
Style = Ref( String );
disc = REF "DISC";
square = REF "SQUARE";
circle = REF "CIRCLE";
fun to_string (REF s) = s;
from_string = match [disc, square, circle];
};
package shape {
Shape = Ref( String );
box = REF "RECT";
circle = REF "CIRCLE";
poly = REF "POLY";
default = REF "DEFAULT";
fun to_string (REF s) = s;
from_string = match [box, circle, poly, default];
};
package text_flow_ctl {
Control = Ref( String );
left = REF "LEFT";
right = REF "RIGHT";
all = REF "ALL";
none = REF "NULL";
fun to_string (REF s) = s;
from_string = match [left, right, all, none];
};
Html = HTML {
version: Null_Or( Cdata ),
head: List( Head_Content ),
body: Body
}
also Head_Content
= HEAD_TITLE Pcdata
| HEAD_ISINDEX { prompt: Null_Or( Cdata ) }
| HEAD_BASE { href: Url }
| HEAD_META {
http_equiv: Null_Or( Name ),
name: Null_Or( Name ),
content: Cdata
}
| HEAD_LINK {
id: Null_Or( Id ),
href: Null_Or( Url ),
rel: Null_Or( Cdata ),
reverse: Null_Or( Cdata ),
title: Null_Or( Cdata )
}
# SCRIPT/STYLE elements are placeholders for the next version of HTML
| HEAD_SCRIPT Pcdata
| HEAD_STYLE Pcdata
also Body = BODY {
background: Null_Or( Url ),
bgcolor: Null_Or( Cdata ),
text: Null_Or( Cdata ),
link: Null_Or( Cdata ),
vlink: Null_Or( Cdata ),
alink: Null_Or( Cdata ),
content: Block
}
also Block
= BLOCK_LIST List( Block )
| TEXTABLOCK Text
| HN {
n: Int,
align: Null_Or( halign::Align ),
content: Text
}
| ADDRESS Block
| PP {
align: Null_Or( halign::Align ),
content: Text
}
| UL {
type: Null_Or( ulstyle::Style ),
compact: Bool,
content: List( List_Item )
}
| OL {
type: Null_Or( Cdata ),
start: Null_Or( Int ),
compact: Bool,
content: List( List_Item )
}
| DIR {
compact: Bool,
content: List( List_Item )
}
| MENU {
compact: Bool,
content: List( List_Item )
}
| DL {
compact: Bool,
content: List { dt: List( Text ), dd: Block }
}
| PRE {
width: Null_Or( Int ),
content: Text
}
| DIV {
align: halign::Align,
content: Block
}
| CENTER Block
| BLOCKQUOTE Block
| FORM {
action: Null_Or( Url ),
method': http_method::Method,
enctype: Null_Or( Cdata ),
content: Block # -(FORM)
}
| ISINDEX { prompt: Null_Or( Cdata ) }
| HR {
align: Null_Or( halign::Align ),
noshade: Bool,
size: Null_Or( Pixels ),
width: Null_Or( Cdata )
}
| TABLE {
align: Null_Or( halign::Align ),
width: Null_Or( Cdata ),
border: Null_Or( Pixels ),
cellspacing: Null_Or( Pixels ),
cellpadding: Null_Or( Pixels ),
caption: Null_Or( Caption ),
content: List( Tr )
}
also List_Item = LI {
type: Null_Or( Cdata ),
value: Null_Or( Int ),
content: Block
}
# * table content *
also Caption = CAPTION {
align: Null_Or( caption_align::Align ),
content: Text
}
also Tr = TR {
align: Null_Or( halign::Align ),
valign: Null_Or( cell_valign::Align ),
content: List( Table_Cell )
}
also Table_Cell
= TH {
nowrap: Bool,
rowspan: Null_Or( Int ),
colspan: Null_Or( Int ),
align: Null_Or( halign::Align ),
valign: Null_Or( cell_valign::Align ),
width: Null_Or( Pixels ),
height: Null_Or( Pixels ),
content: Block
}
| TD {
nowrap: Bool,
rowspan: Null_Or( Int ),
colspan: Null_Or( Int ),
align: Null_Or( halign::Align ),
valign: Null_Or( cell_valign::Align ),
width: Null_Or( Pixels ),
height: Null_Or( Pixels ),
content: Block
}
# * Text *
also Text
= TEXT_LIST List( Text )
| PCDATA Pcdata
| TT Text
| IX Text
| BX Text
| UX Text
| STRIKE Text
| BIG Text
| SMALL Text
| SUB Text
| SUP Text
| EM Text
| STRONG Text
| DFN Text
| CODE Text
| SAMP Text
| KBD Text
| VAR Text
| CITE Text
| AX {
name: Null_Or( Cdata ),
href: Null_Or( Url ),
rel: Null_Or( Cdata ),
reverse: Null_Or( Cdata ),
title: Null_Or( Cdata ),
content: Text # -(A)
}
| IMG {
src: Url,
alt: Null_Or( Cdata ),
align: Null_Or( ialign::Align ),
height: Null_Or( Pixels ),
width: Null_Or( Pixels ),
border: Null_Or( Pixels ),
hspace: Null_Or( Pixels ),
vspace: Null_Or( Pixels ),
usemap: Null_Or( Url ),
ismap: Bool
}
| APPLET {
codebase: Null_Or( Url ),
code: Cdata,
name: Null_Or( Cdata ),
alt: Null_Or( Cdata ),
align: Null_Or( ialign::Align ),
height: Null_Or( Pixels ),
width: Null_Or( Pixels ),
hspace: Null_Or( Pixels ),
vspace: Null_Or( Pixels ),
content: Text
}
| PARAM {
# Applet parameter
name: Name,
value: Null_Or( Cdata )
}
| FONT {
size: Null_Or( Cdata ),
color: Null_Or( Cdata ),
content: Text
}
| BASEFONT {
size: Null_Or( Cdata ),
content: Text
}
| BR {
clear: Null_Or( text_flow_ctl::Control )
}
| MAP {
name: Null_Or( Cdata ),
content: List( Area )
}
| INPUT {
type: Null_Or( input_type::Type ),
name: Null_Or( Cdata ),
value: Null_Or( Cdata ),
checked: Bool,
size: Null_Or( Cdata ),
maxlength: Null_Or( Int ),
src: Null_Or( Url ),
align: Null_Or( ialign::Align )
}
| SELECT {
name: Cdata,
size: Null_Or( Int ),
content: List( Select_Option )
}
| TEXTAREA {
name: Cdata,
rows: Int,
cols: Int,
content: Pcdata
}
# SCRIPT elements are placeholders for the next version of HTML
| SCRIPT Pcdata
# map areas
also Area = AREA {
shape: Null_Or( shape::Shape ),
coords: Null_Or( Cdata ),
href: Null_Or( Url ),
nohref: Bool,
alt: Cdata
}
# SELECT options
also Select_Option = OPTION {
selected: Bool,
value: Null_Or( Cdata ),
content: Pcdata
};
}; # Api Html