Dashboard > SDL > ABNF Grammar
Log In   View a printable version of the current page.
ABNF Grammar
Added by Jesse, last edited by Jesse on Feb 01, 2007  (view change) show comment
Labels: 
(None)


This is the formal ABNF grammar for the current version of SDL. While this page is mainly for developers, if you have a question about a part of SDL, it may be answered here.

Note: LETTER, as it is used here, refers to the definition of Letter found in the W3C XML Recommendation. The first version of the C++ port, as it stands currently, will not conform to this perfectly, although it should accept all Unicode letters. Also, multiline comments are not supported in this version of the grammar.

; Technically, LF and CRLF are the only widely seen forms, but it's easy to add support for CR, so...
NEWLINE = CR / LF / CRLF
UTF8CHAR = <any UTF-8 character>
STRINGCHAR = <any UTF-8 character, besides anything that is escaped>

line-comment = ("//" / "#" / "--") UTF8CHAR NEWLINE

line-start = *WSP
tag-space = SP / ("\" NEWLINE line-start)
line-end = *WSP (line-comment / NEWLINE)

identifier = (LETTER / "_") *(LETTER / DIGIT / "_" / "$" / "." / "-")
name = identifier [":" identifier]

escape-sequence = "\" ("n" / "r" / "t" / "\" / DQUOTE / NEWLINE)
double-quote-string = DQUOTE *(escape-sequence / STRINGCHAR) DQUOTE
backquote-string = "`" *UTF8CHAR "`"
character = "'" UTF8CHAR "'"

integer = 1*DIGIT
long-integer = integer ( "L" / "l" )
float = integer "." integer ( "F" / "f" )
double = integer "." integer [ "D" / "d" ]
decimal = integer "." integer ( "BD" / "bd" )

boolean = "true" / "false" / "on" / "off"

date = 4DIGIT "/" 2DIGIT "/" 2DIGIT
date-time = date 2DIGIT ":" 2DIGIT [":" 2DIGIT ["." 1*3DIGIT]]["-" 3ALPHA]
time-span = [DIGIT ":"] 2DIGIT ":" 2DIGIT ":" 2DIGIT ["." 1*3DIGIT]

binary = "[" *(ALPHA / "/" / "+") [1*2"="] "]"

null = "null"

literal = double-quote-string / backquote-string / character / integer / long-integer / float / double / decimal / boolean / date / date-time / time-span / binary / null

attribute = name "=" literal

tag-children = "{" line-end *(tag / anonymous-tag) "}"
tag = name *(tag-space literal) *(tag-space attribute) [tag-space] tag-children / line-end
anonymous-tag = 1*(literal tag-space) *(attribute tag-space) tag-children / line-end

document = *(tag / anonymous-tag)

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.8 Build:#525 Aug 08, 2006) - Bug/feature request - Contact Administrators