tommy online
home euphoria smel bookmarks sitemap info tommy.blog

smel

definition of SMEL 1.1

Table of contents

BNF-notation - Top Level Structures - Basic Structures - Miscellaneous Structures - Element & Value

BNF-notation

Document ::= SmelDecl Misc* Element Misc*
SmelFragment ::= Misc* ((Element|Value) (Misc* Sep? Misc* (Element|Value) Misc*)*)?

S ::= (' ' | '\t' | '\n' | '\r' | Comment)*
Letter ::= [a-zA-Z]
DecDigit ::= [0-9]
HexDigit ::= [0-9a-fA-F]
Sep ::= S? ',' S?
Eq ::= S? '=' S?
Nil ::= '?'
Sign ::= '+' | '-'
Unit ::= '%' | IdPart
TextChar ::= (Char - '\') | EscapeChar
EscapeChar ::= '\' ('\'|'''|'"'|'t'|'n'|'r'|('#' HexDigit+ '#'))
Id ::= (NameSpaceId ':')? IdPart
NameSpaceId ::= IdPart ('.' IdPart)*
IdPart ::= (Letter | '_') IdChar*
IdChar ::= Letter | DecDigit | '-' | '_'

Misc ::= Directive | S
SmelDecl ::= '<smel' S? AttributeList? S? '>'
Comment ::= '/*' ((Char-'*') | ('*' (Char-'/')))* '*/'
Directive ::= '<' Id S? AttributeList? S? '>'

AttributeList ::= Attribute ((S|Sep)? Attribute)*
Attribute ::= Id | Value | Id Eq Value

Element ::= Id? S? ('(' AttributeList? ')')? (('{' SmelFragment? '}') | (Value? S? ';'))
Value ::= Text | Sequence | Nil | Number | IdValue

Text ::= QuotText | AposText | DelimText | HereDocText
QuotText ::= '"' (TextChar - '"')* '"'
AposText ::= ''' (TextChar - ''')* '''
DelimText ::= '@' Delim (Char - Delim)* Delim
HereDocText ::= '$' S? IdPart (Char* - IdPart)* IdPart

Sequence ::= '[' S? ValueList? S? ']'
ValueList ::= Value ((S|Sep)? Value)*

Number ::= HexInteger | RealNumber
HexInteger ::= '#' HexDigit+
RealNumber ::= Sign? DecDigit+ ('.' DecDigit+)? (('e'|'E') Sign? DecDigit+)? Unit?

IdValue ::= '!' IdPart

Top Level Structures

Document ::= SmelDecl Misc* Element Misc*
A SMEL-document is defined as a SMEL-declaration, followed by a root-element. Miscellaneous structures are allowed before and after the root-element.
SmelFragment ::= Misc* ( (Element|Value) ( Misc* Sep? Misc* (Element|Value) Misc* )* )?
A SMEL-fragment is defined as zero or more elements or values, with an optional separator in between. Miscellaneous structures are allowed between the elements/values.

Basic Structures

S ::= ( ' ' | '\\t' | '\\n' | '\\r' | Comment )*
A whitespace is defined as zero or more instances of one of the space-characters (space, tab, newline or return) or comments.
Letter ::= [a-zA-Z]
A letter is defined as a character in the range of 'a' to 'z' or 'A' to 'Z'.
DecDigit ::= [0-9]
A decimal digit is defined as a character in the range of '0' to '9'.
HexDigit ::= [0-9a-fA-F]
A hexadecimal digit is defined as a character in the range of '0' to '9' or 'a' to 'f' or 'A' to 'F'.
Sep ::= S? ' S?
A separator is defined as the character ',' with optional whitespace before and after it.
Eq ::= S? '=' S?
An equal-token is defined as the character '=' with optional whitespace before and after it.
Nil ::= '?'
Nil is defined as a question mark.
Sign ::= '+' | '-'
A sign is defined as one of the characters '+' or '-'.
Unit ::= '%' | IdPart
A unit is defined as the percentage-character or as an ID-part.
TextChar ::= ( Char - '\\' ) | EscapeChar
A text-character is defined as any character except '\', or as an escape-character.
EscapeChar ::= '\\' ( '\\' | ''' | '\"' | 't' | 'n' | 'r' | ( '#' HexDigit+ '#' ) )
An escape-character is defined as a '\' followed by one of the characters '\', ''', '"', 't', 'n', 'r' or one or more hexadecimal digits between 2 '#'-characters.
Id ::= ( NameSpaceId ':' )? IdPart
An ID is defined as an ID-part, with an optional namespace-ID and ':' before it.
Examples:
abcd
_X002
System.Windows.Forms:Form
NameSpaceId ::= IdPart ( '.' IdPart )*
A namespace-ID is defined as one or more ID-parts, separated by '.'-characters.
Examples:
System.Windows.Forms
java.util.HashMap
euphoria.windows.Win32Lib
IdPart ::= ( Letter | '_' ) IdChar*
An ID-part is defined as a series of ID-characters. The first character has to be a letter or an underscore.
IdChar ::= Letter | DecDigit | '-' | '_'
An ID-character is defined as a letter, a decimal digit, a '-'-character or an underscore.

Miscellaneous Structures

Misc ::= Directive | S
A miscellaneous structure is defined as a directive or a whitespace.
SmelDecl ::= '<smel' S? AttributeList? S? '>'
A SMEL-declaration is defined as '<smel>', with an optional attribute-list. It has some specific attributes.
Example: <smel version="1.1" ns="smel.test">
Comment ::= '/*' ( ( Char-'*' ) | ( '*' ( Char-'/' ) ) )* '*/'
A comment is defined as zero or more characters between '/*' and '*/'.
Example: /* just some comments */
Directive ::= '<' Id S? AttributeList? S? '>'
A directive is defined as an ID and an optional attribute-list, between '<' and '>'. The SMEL-standard also has some special directives.
Example: <smel:meta author="Santa Claus" generator="Notepad">
AttributeList ::= Attribute ( (S|Sep)? Attribute )*
An attribute-list is defined as a series of attributes, with an optional separator or space in between.
Attribute ::= Id | Value | Id Eq Value
An attribute is defined as an ID, a value, or an ID and a value with an equal-token in between.
Examples:
name = "value"
checked
'value'
width=75%
ratio=3/4
id = !x102

Element & Value

Element ::= Id? S? ( '(' AttributeList? ''")> )? ( ( '{' SmelFragment? '}' ) | ( Value? S? ';' ) )
An element is defined as an optional ID with an optional attribute-list between '(' and ')', and a SMEL-fragment between '{' and '}' or an optional value with a ';'.
Examples:
element1 (attr1 = "value1", attr2 = 3/4) { 1, 2, 3 }
element2 {[1,2,3], [4,5,6], [7,8,9]}
(attr = #3F6) 'Anonymous element';
element3;
Value ::= Text | Sequence | Nil | Number | IdValue
A value is defined as a text, a sequence, a nil, a number or an ID-value.
Text ::= QuotText | AposText | DelimText | HereDocText
A text is defined as a text between quotes, a text between apostrophes, a delimited text or a HereDoc-text.
QuotText ::= '\"' ( TextChar - '\"' )* '\"'
A text between quotes is defined as a series of text-characters without '"', delimited by quotes.
Examples:
"Just a string of text"
"To insert special characters like \\" or \\#69#"
AposText ::= ''' ( TextChar - ''' )* '''
A text between apostrophes is defined as a series of text-characters without ''', delimited by apostrophes.
Examples:
'Just a string of text'
'To insert special characters like \\''
DelimText ::= '@' Delim ( Char - Delim )* Delim
A delimited text is defined as a '@' followed by a delimiter, a series of characters, and the same delimiter.
Examples:
@"In delimited text"
@#Just don't use the delimiter in your text.#
@$Choose a delimiter that you don't expect to use in the text.$
HereDocText ::= '$' S? IdPart ( Char* - IdPart )* IdPart
A heredoc-text is defined as a '$' followed by an identifier, a series of characters, and the same identifier.
Examples:
$ END In heredoc-text
$ END_OF_TEXT Just don't use the delimiter-identifier in your text. END_OF_TEXT
$ XYZ Choose a delimiter-identifier that you don't expect to use in the text. XYZ
Sequence ::= '[' S? ValueList? S? ']'
A sequence is defined as a value-list between '[' and ']'.
Examples:
[1, 2, 3]
[4 5 6 7 8]
[[1, 2, 3][4 5 6],[7, 8, 9]]
["John", "Mary", ["Billy", "William"]]
[ 0.25%, +12px, 12.17inch, #FF6C, 12.34e-67, !x101, !x102 ]
ValueList ::= Value ( (S|Sep)? Value )*
A value-list is defined as a series of values with an optional separator or space in between.
Number ::= HexInteger | RealNumber
A number is defined as a hexadecimal integer or a real number.
HexInteger ::= '#' HexDigit+
A hexadecimal integer is defined as a '#' and one or more hexadecimal digits.
RealNumber ::= Sign? DecDigit+ ( '.' DecDigit+ )? ( ('e'|'E') Sign? DecDigit+ )? Unit?
A real number is defined as an optional sign, a decimal number, with an optional '.' and decimal number, an optional 'e' or 'E' and decimal number, followed by an optional unit.
IdValue ::= '!' IdPart
An ID-value is defined as a '!' followed by an ID-part.
This is the printed version of a page from tommy online: http://users.telenet.be/tommycarlier
Copyright © 2003 - 2005 Tommy Carlier ()
smel: intro tutorial smel 1.1 <smel:...>
Opera WebBrowser