diff --git a/coml.ebnf b/coml.ebnf index 318b4c6..f2f29f5 100644 --- a/coml.ebnf +++ b/coml.ebnf @@ -13,28 +13,31 @@ basicTypes ::= number | boolean | string | array | hash | patchKey | patch | "ni (* Basic Types: Number *) -digit ::= #'[1-9]'; -natural ::= digit | "0" | natural "0" | digit natural; -decInteger ::= natural | "-" natural | "+" natural; -float ::= decInteger "f" - | decInteger "." natural - | decInteger "." natural "e" decInteger - | decInteger "." natural "E" decInteger; +decDigit ::= #'[0-9]'; +nonZeroDecDigit ::= #'[1-9]'; +decInteger ::= "0" | nonZeroDecDigit decDigit*; + +exponentIndicator ::= "e" | "E"; +exponentPart ::= exponentIndicator decDigit+ + | exponentIndicator "-" decDigit+ + | exponentIndicator "+" decDigit+; +unsignedFloat ::= decInteger "f" + | decInteger "." decDigit+ exponentPart*; binDigit ::= #'[0-1]'; -binNature ::= "0b" binDigit+; -binInteger ::= binNature | "-" binNature | "+" binNature; +binInteger ::= "0b" binDigit+; octDigit ::= #'[0-7]'; -octNature ::= "0o" octDigit+ | "0" octDigit+; -octInteger ::= octNature | "-" octNature | "+" octNature; +octInteger ::= "0o" octDigit+ | "0" octDigit+; hexDigit ::= #'[0-9a-fA-F]'; -hexNature ::= "0x" hexDigit+; -hexInteger ::= hexNature | "-" hexNature | "+" hexNature; +hexInteger ::= "0x" hexDigit+; + +unsignedInteger ::= decInteger | binInteger | octInteger | hexInteger; +signedInteger ::= unsignedInteger | "-" unsignedInteger | "+" unsignedInteger; +signedFloat ::= unsignedFloat | "-" unsignedFloat | "+" unsignedFloat; -integer ::= decInteger | binInteger | octInteger | hexInteger; -number ::= integer | float; +number ::= signedInteger | signedFloat; (* Basic Types: Boolean *) @@ -56,7 +59,7 @@ array ::= "[" splitter? arrayElements splitter? "]" keyCharStart ::= #'[a-zA-Z_]'; -keyCharMiddle ::= keyCharStart | digit | "0" | "_"; +keyCharMiddle ::= keyCharStart | decDigit; key ::= keyCharStart keyCharMiddle*; hashElement ::= (whitespaces?) key (splitter?) ":" (splitter?) expr; hash ::= hashElement | hashElement eol+ hash; @@ -73,9 +76,9 @@ imports ::= import | import eol+ imports; (* Patch *) patchKey ::= patchKey "." key - | patchKey "[" whitespaces? (string | integer) whitespaces? "]" - | patchKey "[" whitespaces? integer whitespaces? ".." whitespaces? integer whitespaces? "]" - | patchKey "[" whitespaces? integer whitespaces? "..." whitespaces? integer whitespaces? "]" + | patchKey "[" whitespaces? (string | signedInteger) whitespaces? "]" + | patchKey "[" whitespaces? signedInteger whitespaces? ".." whitespaces? signedInteger whitespaces? "]" + | patchKey "[" whitespaces? signedInteger whitespaces? "..." whitespaces? signedInteger whitespaces? "]" | key; patchReplace ::= patchKey whitespaces? "=" splitter? expr;