Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static class: RT.Util.RhoML

Summary

Exposes methods related to the RhoML language. See Remarks.

Remarks

RhoML is a language which parses into a tree somewhat reminiscent of XML. The document is represented by a root RhoElement, and consists of a tree of RhoNodes. Two types of nodes exist: elements, which have a name and may have attributes, and text nodes, which simply contain raw text. Only elements may contain sub-nodes.

Except for the root element, all elements must have a name, which can be an arbitrary string. The root element's name is null. An element may have a default attribute value, as well as any number of additional named attribute/value pairs. The attribute names and values can also be arbitrary strings. A named attribute is not required to have a value.

Syntactically, an element is delimited by an opening and a closing tag. The closing tag is always {} for all elements. The opening tag begins with a {, followed by the element name, the default attribute value (= followed by the value), any number of named attributes (name, =, value, delimited by ,), and ends with a }.

The following is an example of valid RhoML with an explanation of what is represented:

Basic {font=Times New Roman}example{}: element named "font" with the default attribute set.
 Another {blah,foo=bar,stuff}example{}: element named "blah", no default attribute, two named attributes
 ("foo" and "stuff"), the first of which has the value "bar" while the second one has no value. Other than the
 two elements, the rest of this RhoML is literal text.

The element name and attribute names/values can all be specified using either quoted or unquoted syntax. Unquoted syntax is limited in what strings can be expressed, while quoted syntax allows every possible string to be represented:

  • Unquoted values always terminate at {, }, =, ,, `, newlines and tabs, and these cannot be escaped. All other characters are allowed and are interpreted literally. Spaces are allowed but leading and trailing spaces will be ignored.
  • Quoted values begin and end with a `. Actual backticks can be represented by ``. All other characters are interpreted literally inside a quoted value, and there are no special escape sequences for newlines or other non-printing characters.

Whitespace is significant in all contexts, with some exceptions inside the opening tag of an element. Specifically, whitespace is ignored inside the opening tag between all syntactic elements (but not inside names/values), with the sole exception of immediately after {: this character must be followed by a ` (beginning the element name in quoted syntax) or a Unicode letter or digit (beginning the tag name in unquoted syntax). Otherwise the { character is interpreted as a literal opening curly bracket.

Within a run of text, only the { character needs special attention; all other characters are interpreted literally. The { character is also interpreted literally unless followed by a { (in which case the two are interpreted as a single literal curly bracket), } (interpreted as the closing tag), or a `/letter/digit (interpreted as the start of an opening tag).

A more complex example (the entire example is valid RhoML):

This curly bracket { is interpreted literally, as is this } one. This {{ is a single open curly.
Here {` is ``{ `}an element{} whose name is " is `{ ", containing a text node with the text "an element".
Here's an element with some generous {use = of spaces ,   you   =   see}.{}; this represents an element named
"use", with a default attribute value "of spaces", and an attribute named "you" with a value "see".

Static methods

string
Escape(string str)
Escapes the specified string so that when parsed as RhoML, the result is a single text node containing the string passed in.
RhoElement
Parse(string input)
Parses the specified string as RhoML.