From 6bf9ef06e78aeccd1a8ad91aa537136182b09009 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 22:02:39 -0800 Subject: [PATCH 1/7] EBNF --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 017b9b7e..d2292daf 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,53 @@ type = "apple" apple = "yes" ``` +EBNF Like a Boss +---------------- +```text +Array ::= '[' \ + STRING {',' STRING } \ + | INTEGER {',' INTEGER } \ + | FLOAT {',' FLOAT } \ + | BOOLEAN {',' BOOLEAN } \ + | DATETIME {',' DATETIME} \ + | Array {',' Array } \ + ']' + +Value ::= STRING | INTEGER | FLOAT | BOOLEAN | DATETIME | Array + +KeyValue ::= KEY '=' Value + +KeyGroup ::= '[' KEYGROUPNAME ']' + +ROOT ::= (KeyGroup | KeyValue)* + +##### Tokens + +## NonTerminals +COMMENT = #.*^ +WHITESPACE = [\ \t] + +## Terminals +KEY = [^\.]+ +KEYGROUPNAME = KEY ( '.' KEY )* +STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '" +DIGIT = [0-9] +DIGITS = Digit+ +SIGN = [\-] +INTEGER = '0'|(SIGN? [1-9] Digit*) +# Lets have exponents, nans and infinity so we're not nonstandard douchebags +FLOAT = ( (INTEGER '.') \ + | (((SIGN? '0'?)| INTEGER)? '.' DIGITS) \ + ( 'e' INTEGER) ) \ + | SIGN? ( [sq]'nan' | 'inf' ) +BOOLEAN = TRUE | FALSE +TRUE = 'true' +FALSE = 'false' +DATE = DIGIT{4} '-' DIGIT{2} '-' DIGIT{2} +TIME = DIGIT{2} ':' DIGIT{2} ':' DIGIT{2} +DATETIME = DATE 'T' TIME 'Z' +``` + Seriously? ---------- From 32f09c6614829a1601fc4deb24f40aeb0a97e4c8 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 22:28:13 -0800 Subject: [PATCH 2/7] allow newlines in ARRAY whitespace --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d2292daf..d143ef0c 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,7 @@ ROOT ::= (KeyGroup | KeyValue)* ## NonTerminals COMMENT = #.*^ WHITESPACE = [\ \t] +ARRAY_WHITESPACE = [\ \t\r\n] ## Terminals KEY = [^\.]+ From f623083a5e10bf9192583f1e617333ea73685455 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 23:02:19 -0800 Subject: [PATCH 3/7] Clean up FLOAT terminal --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d143ef0c..b4e1450e 100644 --- a/README.md +++ b/README.md @@ -224,12 +224,11 @@ KEY = [^\.]+ KEYGROUPNAME = KEY ( '.' KEY )* STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '" DIGIT = [0-9] -DIGITS = Digit+ SIGN = [\-] -INTEGER = '0'|(SIGN? [1-9] Digit*) +INTEGER = '0'|(SIGN? [1-9] DIGIT*) # Lets have exponents, nans and infinity so we're not nonstandard douchebags FLOAT = ( (INTEGER '.') \ - | (((SIGN? '0'?)| INTEGER)? '.' DIGITS) \ + | (((SIGN? '0'?)| INTEGER)? '.' DIGIT+) \ ( 'e' INTEGER) ) \ | SIGN? ( [sq]'nan' | 'inf' ) BOOLEAN = TRUE | FALSE From d8fa845d0e74cc8102dd717690ca8df3107a7f2f Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 23:26:02 -0800 Subject: [PATCH 4/7] DIGIT velvet rope deny --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b4e1450e..22bfac42 100644 --- a/README.md +++ b/README.md @@ -223,19 +223,18 @@ ARRAY_WHITESPACE = [\ \t\r\n] KEY = [^\.]+ KEYGROUPNAME = KEY ( '.' KEY )* STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '" -DIGIT = [0-9] SIGN = [\-] -INTEGER = '0'|(SIGN? [1-9] DIGIT*) +INTEGER = '0'|(SIGN? [1-9] [0-9]*) # Lets have exponents, nans and infinity so we're not nonstandard douchebags FLOAT = ( (INTEGER '.') \ - | (((SIGN? '0'?)| INTEGER)? '.' DIGIT+) \ + | (((SIGN? '0'?)| INTEGER)? '.' [0-9]+) \ ( 'e' INTEGER) ) \ | SIGN? ( [sq]'nan' | 'inf' ) BOOLEAN = TRUE | FALSE TRUE = 'true' FALSE = 'false' -DATE = DIGIT{4} '-' DIGIT{2} '-' DIGIT{2} -TIME = DIGIT{2} ':' DIGIT{2} ':' DIGIT{2} +DATE = [0-9]{4} '-' [0-9]{2} '-' [0-9]{2} +TIME = [0-9]{2} ':' [0-9]{2} ':' [0-9]{2} DATETIME = DATE 'T' TIME 'Z' ``` From d4a2648212d7d53984de0b99f2846a8a20bc2996 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 23:47:27 -0800 Subject: [PATCH 5/7] Explicit whitespace distinction Whitespace is not included in productions because it makes a mess. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 22bfac42..b04d173c 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,7 @@ apple = "yes" EBNF Like a Boss ---------------- ```text + Array ::= '[' \ STRING {',' STRING } \ | INTEGER {',' INTEGER } \ @@ -202,7 +203,8 @@ Array ::= '[' \ | BOOLEAN {',' BOOLEAN } \ | DATETIME {',' DATETIME} \ | Array {',' Array } \ - ']' + ']' // whitespace = ARRAY_WHITESPACE + Value ::= STRING | INTEGER | FLOAT | BOOLEAN | DATETIME | Array @@ -210,16 +212,14 @@ KeyValue ::= KEY '=' Value KeyGroup ::= '[' KEYGROUPNAME ']' -ROOT ::= (KeyGroup | KeyValue)* +ROOT ::= (KeyGroup | KeyValue)* // whitespace = WHITESPACE ##### Tokens -## NonTerminals COMMENT = #.*^ WHITESPACE = [\ \t] ARRAY_WHITESPACE = [\ \t\r\n] -## Terminals KEY = [^\.]+ KEYGROUPNAME = KEY ( '.' KEY )* STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '" From 22b492e6fdf8b8d1820f40be88d5ae45c908b517 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Sat, 23 Feb 2013 23:52:13 -0800 Subject: [PATCH 6/7] Even more explicit // is a comment. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b04d173c..27e6bd70 100644 --- a/README.md +++ b/README.md @@ -208,9 +208,9 @@ Array ::= '[' \ Value ::= STRING | INTEGER | FLOAT | BOOLEAN | DATETIME | Array -KeyValue ::= KEY '=' Value +KeyValue ::= KEY '=' Value // whitespace = WHITESPACE -KeyGroup ::= '[' KEYGROUPNAME ']' +KeyGroup ::= '[' KEYGROUPNAME ']' // whitespace = WHITESPACE ROOT ::= (KeyGroup | KeyValue)* // whitespace = WHITESPACE From 7f8c042686092d2d6f479753e78d27f3d1ae15a7 Mon Sep 17 00:00:00 2001 From: Barry Allard Date: Fri, 23 Aug 2013 21:53:06 -0700 Subject: [PATCH 7/7] updates --- README.md | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 27e6bd70..66a3210f 100644 --- a/README.md +++ b/README.md @@ -203,38 +203,33 @@ Array ::= '[' \ | BOOLEAN {',' BOOLEAN } \ | DATETIME {',' DATETIME} \ | Array {',' Array } \ - ']' // whitespace = ARRAY_WHITESPACE + ']' // whitespace = .ARRAY_WHITESPACE Value ::= STRING | INTEGER | FLOAT | BOOLEAN | DATETIME | Array -KeyValue ::= KEY '=' Value // whitespace = WHITESPACE +KeyValue ::= KEY '=' Value // whitespace = .WHITESPACE -KeyGroup ::= '[' KEYGROUPNAME ']' // whitespace = WHITESPACE +KeyGroup ::= '[' KEYGROUPNAME ']' // whitespace = .WHITESPACE -ROOT ::= (KeyGroup | KeyValue)* // whitespace = WHITESPACE +ROOT ::= (KeyGroup | KeyValue)* // whitespace = .WHITESPACE ##### Tokens -COMMENT = #.*^ -WHITESPACE = [\ \t] -ARRAY_WHITESPACE = [\ \t\r\n] +.COMMENT = #.*^ +.WHITESPACE = [\ \t] +.ARRAY_WHITESPACE = [\ \t\r\n] -KEY = [^\.]+ +KEY = [^\.\[\]=\ \t]+ KEYGROUPNAME = KEY ( '.' KEY )* -STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '" -SIGN = [\-] -INTEGER = '0'|(SIGN? [1-9] [0-9]*) -# Lets have exponents, nans and infinity so we're not nonstandard douchebags -FLOAT = ( (INTEGER '.') \ - | (((SIGN? '0'?)| INTEGER)? '.' [0-9]+) \ - ( 'e' INTEGER) ) \ - | SIGN? ( [sq]'nan' | 'inf' ) -BOOLEAN = TRUE | FALSE -TRUE = 'true' -FALSE = 'false' -DATE = [0-9]{4} '-' [0-9]{2} '-' [0-9]{2} -TIME = [0-9]{2} ':' [0-9]{2} ':' [0-9]{2} +STRING = '"' ([^\"\\]|'\\'[0tnr"\\])* '"' +UNSIGNED_INTEGER = '0' | ( [1-9] [0-9]* ) +INTEGER = '-'? UNSIGNED_INTEGER +FLOAT = INTEGER '.' UNSIGNED_INTEGER // "in the next release": .... ( [eE] INTEGER )? +BOOLEAN = 'true' | 'false' +NN = [0-9]{2} +DATE = [0-9]{4} '-' NN '-' NN +TIME = NN ':' NN ':' NN DATETIME = DATE 'T' TIME 'Z' ```