Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions coml.ebnf
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)

Expand All @@ -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;
Expand All @@ -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;
Expand Down