% A comment should be allowed anywhere

diagram_class("Trees, AVMs and DRSs", "1.0")
dtd_name("treeavm.dtd")

diagram_spec(top, hbox([align(center),separator(space([height(0),width(20)]))],
	                [var(drs, [elements])]))



diagram_union(elements, [tree_top, value]) % like here for example

diagram_union(tree_top, [one_branch, two_branch, three_branch])

diagram_union(leaf_or_tree, [one_branch, two_branch, three_branch, lexical, referent, value])


diagram_union(category, [plain_category, avm])

diagram_union(avm, [sorted_avm, tagged_sorted_avm, plain_avm])

diagram_spec(plain_category, plain(var(cat, Text)))

diagram_spec(sorted_avm, hbox([align(bottom)], [var(sort, sort),
		var(avm, plain_avm)]))

diagram_spec(sort, italic(var(id, Text)))

diagram_spec(plain_avm, bracket([delimiter(square)],
vbox([padding(space([width(0), height(3)])), align(left)], var(avpairs, [avm_element]))))

diagram_union(avm_element, [avpair, path_value])

diagram_spec(avpair, array_element([align(centre)], [var(attribute, attribute), var(value, value)]))

diagram_spec(tagged_avm, hbox([align(centre)], [var(tag, tag), var(avm, plain_avm)]))

diagram_spec(tagged_sorted_avm, hbox([], [vbox([align(right)], [space([expand]), var(tag, tag),
	space([expand]), var(sort, sort)]), var(avm, plain_avm)]))

diagram_spec(attribute, smallcaps(var(name, Text)))

diagram_union(value, [atomic_value, sort, avm, drs, set, sequence, alias, tag])

diagram_union(alias, [category_alias, subscripted_category_alias, category_and_attributes])

diagram_spec(category_alias, plain(var(alias, Text)))

diagram_spec(category_and_attributes, 
	hbox([var(category, category_alias),
	      var(attributes, feature_list)]))

diagram_union(flist_element,
	[avpair, sort])

diagram_spec(feature_list, 
	bracket([delimiter(square)], 
		hbox([var(list, [flist_element])])))

diagram_spec(subscripted_category_alias, 
	hbox([align(bottom), baseline(20), separator(nothing())], 
		[vbox([var(category, category_alias), space([height(5)])]),
		 italic(var(subscript, Text))]))
		

diagram_spec(tag, box([padding(space([height(2), width(2)]))], smallcaps(var(id, Text))))

diagram_spec(set, bracket([delimiter(curly)], 
	hbox([align(bottom), separator(plain(", "))], var(set_els, [value]))))

diagram_spec(sequence, bracket([delimiter(angle)], 
	hbox([align(bottom), separator(plain(", "))], var(seq_els, [value]))))

diagram_spec(path_value, hbox([align(bottom)], [var(path, nonempty_path),
	var(value, value)]))

diagram_spec(nonempty_path, 
	hbox([align(centre), separator(nothing())], 
		[var(attribute, attribute), smallcaps("|"), var(rest,
			path_end)]))

diagram_union(path_end, [attribute, nonempty_path])

diagram_spec(atomic_value, plain(var(val, Text)))

diagram_spec(lexical, italic(var(lex, Text)))


diagram_spec(drs,
	     box([padding(nothing())], 
		 vbox([align(left)],
		      [hbox([padding(space())],
	                    [var(universe, [referent])]),
% Comment out the following line to get K&R behaviour
		       line([expand]),
		       vbox([align(left), padding(space())],
	                    [var(conditions, [condition])])])))

diagram_spec(referent,
	     italic(var(id, Text)))

diagram_union(condition, [atomic, equation, implication, tree_top])

diagram_spec(equation,
	     hbox([],
		  [var(lhs, referent),
		   plain("="),
		   var(rhs, referent)]))

diagram_spec(implication,
	     hbox([align(centre)],
		  [var(lhs, drs),
		   plain(" -> "),
		   var(rhs, drs)]))

diagram_spec(atomic, 
	     hbox([separator(nothing())],
		  [var(relation, rel_symbol),
		   bracket([delimiter(round)],
			 hbox([separator(hbox([separator(nothing())],
					      [plain(","),
					       space([width(5),height(0)])]))],
			       [var(referents, [referent])]))]))

diagram_spec(rel_symbol, plain(var(symbol, Text)))

diagram_spec(one_branch, 
		tree([var(mother, category), var(daughter, leaf_or_tree)]))

diagram_spec(two_branch, 
		tree([var(mother, category), var(daughter_one, leaf_or_tree),
					     var(daughter_two, leaf_or_tree)]))

diagram_spec(three_branch, 
		tree([var(mother, category), var(daughter_one, leaf_or_tree),
					     var(daughter_two, leaf_or_tree),
					     var(daughter_three, leaf_or_tree)]))




start
