Skip to content

Instantly share code, notes, and snippets.

@statonjr
Forked from bjeanes/edn.bnf
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statonjr/cffd72c5fc66604f6abe to your computer and use it in GitHub Desktop.
Save statonjr/cffd72c5fc66604f6abe to your computer and use it in GitHub Desktop.
EDN ::= Whitespace (Comment | (Discard Whitespace)? (Tag Whitespace)? (List | Vector | Map | Set | String | Number | Keyword | Symbol | Nil | Boolean | Char) Whitespace Comment?)
Nil ::= "nil"
True ::= "true"
False ::= "false"
Boolean ::= True | False
Symbol ::= (Namespace "/")? ("/" | (Alphabetic Alphanumeric*)? (("-" | "." | "+")? Alphabetic | ("*" | "!" | "_" | "?" | "$" | "%" | "&" | "=")) (Alphanumeric | "#" | ":")*) /* FIXME: very inaccurate */
Keyword ::= ":" Symbol
/* Whitespace */
Whitespace ::= (Space | Tab | Comma)*
Space ::= " "
Tab ::= "\t"
Comma ::= ","
/* Data Structures */
List ::= "(" EDN* ")"
Vector ::= "[" EDN* "]"
Map ::= "{" (EDN EDN)* "}"
Set ::= "#{" EDN* "}" /* TODO: duplicate semantics */
String ::= '"' UTF8Char* '"' /* TODO: define UTF8Char — handle escaping */
Character ::= "\" (Alphabetic | "newline" | "tab" | "return" | "space") /* numbers? */
/* Numbers */
NonZeroDigit ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
ZeroDigit ::= "0"
Digit ::= ZeroDigit | NonZeroDigit
Digits ::= ZeroDigit | (NonZeroDigit Digit*)
Integer ::= NonZeroDigit* "N"
Float ::= Digits ("M" | (Digits (Fraction | (Fraction? Exponent)) "M"?))
Fraction ::= "." Digit+
Exponent ::= ("e" | "E") Sign? Digits
Sign ::= "+" | "-"
Number ::= Sign? (Integer | Float)
/* Misc */
Comment ::= ";" UTF8Char* NewLine
NewLine ::= "\r\n" | "\n" | "\r"
UpperAlphabetic ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
LowerAlphabetic ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"
Alphabetic ::= UpperAlphabetic | LowerAlphabetic
Namespace ::= LowerAlphabetic+ ("." LowerAlphabetic+)*
Tag ::= "#" (Namespace "/") Alphabetic+
Discard ::= "#_"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment