define TCS language and prove stage0 execution slice
This commit is contained in:
parent
8cfdba210f
commit
3959ae4270
31 changed files with 2449 additions and 5 deletions
34
language/grammar/TCS-CORE-v0.1.ebnf
Normal file
34
language/grammar/TCS-CORE-v0.1.ebnf
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
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 全部拒绝。 *)
|
||||
(* 字段顺序不改变语义哈希;列表顺序保留。 *)
|
||||
|
||||
Loading…
Reference in a new issue