Created
March 4, 2025 16:32
-
-
Save acarabott/6041e0a1b7fa45c7a6d61ee0c7d79f68 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
Protocol { | |
Item = | |
| Constant | |
| Model | |
| Enum | |
Property = ident ":" Type | |
Model = "model" ident "{" ListOf<Property, ";"> "}" | |
Constant = | |
| GenericConstant<ArrayType, Array> | |
| GenericConstant<EnumName, EnumValue> | |
| GenericConstant<StringType, string> | |
| GenericConstant<NumberType, number> | |
| GenericConstant<BooleanType, boolean> | |
GenericConstant<T, E> = "const" Property "=" E ";" | |
Type = | |
| RecordType | |
| ArrayType | |
| EnumName | |
| NumberType | |
| StringType | |
| BooleanType | |
RecordType = Type "{}" | |
ArrayType = Type "[]" | |
StringType = "string" | |
BooleanType = "boolean" | |
Array = "[" ListOf<primitive, ","> "]" | |
Enum = "enum" EnumName "{" ListOf<ident, ","> "};" | |
EnumValue = EnumName "." ident | |
EnumName = upper+ alnum* | |
NumberType = | |
| "i8" | "u8" | |
| "i16" | "u16" | |
| "i32" | "u32" | |
| "i64" | "u64" | |
| "f32" | "f64" | |
ident (an identifier) | |
= letter alnum* | |
primitive = | |
| number | |
| string | |
| boolean | |
boolean = "true" | "false" | |
string //TODO use string definition from es5 grammar | |
= "\"" alnum* "\"" | |
number | |
= digit* "." digit+ -- decimal | |
| digit+ -- integer | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment