Created
June 9, 2013 21:12
-
-
Save enjoysmath/5745244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SDLangGrammar: | |
################# | |
###### Tags ##### | |
################# | |
Tag < Name? (Value :Spacing)* (Attribute :Spacing)* ('=' '{' (Tag :Spacing)* '}')? | |
Attribute < Name '=' Literal | |
Name < Identifier ':' Identifier | |
Identifier <~ ![0-9] IdChar+ | |
IdChar <- ![=:{}#/] !backquote !quote !doublequote !backslash . | |
##################### | |
###### Literals ##### | |
##################### | |
Literal <- Null / Base64 / TimeSpan / DateTime / Number / Char / String | |
Null <- "null" | |
#---- base 64 ---- | |
Base64 <~ (Alpha / alpha / digit / '+' / '/')+ ("=" / "==" / "===")? | |
#---- date & time ---- | |
TimeSpan <- (digits 'd:')? Hour ':' Minute ':' Second ('.' Milsec)? | |
DateTime <- Year '/' Month '/' Day (:Spacing Hour ':' Minute (':' Second ('.' Milsec)?)? ('-' Zone)?)? | |
Year <~ digit digit digit digit | |
Month <~ digit digit | |
Day <~ digit digit | |
Hour <~ digit digit | |
Minute <~ digit digit | |
Second <~ digit digit | |
Milsec <~ digit digit digit | |
Zone <~ Alpha Alpha? Alpha? Alpha? Alpha? | |
#---- number literals ---- | |
Number <- Boolean / Decimal / Double / Float / LongInteger / Integer | |
Boolean <- "true" / "false" / "on" / "off" | |
Decimal <- Sign? digits '.' digits ("BD" / "bd") | |
Double <- Sign? digits '.' digits ('D' / 'd' / eps) | |
Float <- Sign? digits '.' digits ('F' / 'f') | |
LongInteger <- Sign? digits ('L' / 'l') | |
Integer <- Sign? digits | |
Sign <- '-' / '+' | |
#---- character literal ---- | |
Char <- quote !quote . quote | |
#---- string literals ---- | |
String <- DoublequoteString / BackquoteString | |
DoublequoteString <- doublequote (!doublequote backslash('n' / 'r' / 't' / backslash / doublequote / eol) / .)* doublequote | |
BackquoteString <- backquote ~(!backquote .)* backqoute | |
############################### | |
###### Spacing & Comments ##### | |
############################### | |
# space arrow "< " in a Pegged rule implicitly uses this Spacing definition between each expression, except in e* & e+. | |
# For those do (e :Spacing)+. | |
Spacing <- (blank / Comment)+ | |
Comment <: LineComment / BlockComment | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment