hololake-system-architecture/language/grammar/TCS-CORE-v0.1.ebnf

34 lines
1.6 KiB
EBNF
Raw Permalink Normal View History

document = prologue, declaration, EOF ;
prologue = "TCS", version, ";" ;
version = integer, ".", integer ;
declaration = declaration_kind, identifier, block ;
declaration_kind = "PROGRAM" | "MODULE" | "PROTOCOL" | "COMPILER" | "EVENT" | "RECEIPT" ;
block = "{", { member }, "}" ;
member = identifier, ( typed_assignment | assignment | block ) ;
typed_assignment = ":", type_expression, "=", value, ";" ;
assignment = "=", value, ";" ;
value = string | integer | boolean | null | identifier | array | inline_object ;
array = "[", [ value, { ",", value } ], "]" ;
inline_object = "{", [ pair, { ",", pair } ], "}" ;
pair = identifier, ":", value ;
type_expression = identifier, [ "<", type_expression, { ",", type_expression }, ">" ] ;
boolean = "true" | "false" ;
null = "null" ;
integer = [ "-" ], digit, { digit } ;
identifier = identifier_start, { identifier_continue } ;
identifier_start = unicode_letter | "_" ;
identifier_continue = unicode_letter | digit | "_" | "-" | "." | "/" | ":" | "@" ;
string = '"', { json_string_character }, '"' ;
line_comment = "//", { any_character_except_line_break } ;
block_comment = "/*", { any_character_not_closing_comment }, "*/" ;
whitespace = " " | "\t" | "\n" | line_comment | block_comment ;
(* v0.1 *)
(* PROGRAM *)
(* token *)
(* *)