Appendix

Containers

A container in Zig is any syntactical construct that acts as a namespace to hold variable and function declarations. Containers are also type definitions which can be instantiated. Structs, enums, unions, opaques, and even Zig source files themselves are containers.

Although containers (except Zig source files) use curly braces to surround their definition, they should not be confused with blocks or functions. Containers do not contain statements.

Grammar

grammar.y

  1. Root <- skip container_doc_comment? ContainerMembers eof
  2. # *** Top level ***
  3. ContainerMembers <- ContainerDeclarations (ContainerField COMMA)* (ContainerField / ContainerDeclarations)
  4. ContainerDeclarations
  5. <- TestDecl ContainerDeclarations
  6. / TopLevelComptime ContainerDeclarations
  7. / doc_comment? KEYWORD_pub? TopLevelDecl ContainerDeclarations
  8. /
  9. TestDecl <- doc_comment? KEYWORD_test STRINGLITERALSINGLE? Block
  10. TopLevelComptime <- doc_comment? KEYWORD_comptime BlockExpr
  11. TopLevelDecl
  12. <- (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE? / (KEYWORD_inline / KEYWORD_noinline))? FnProto (SEMICOLON / Block)
  13. / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl
  14. / KEYWORD_usingnamespace Expr SEMICOLON
  15. FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? CallConv? EXCLAMATIONMARK? TypeExpr
  16. VarDecl <- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON
  17. ContainerField <- doc_comment? KEYWORD_comptime? IDENTIFIER (COLON (KEYWORD_anytype / TypeExpr) ByteAlign?)? (EQUAL Expr)?
  18. # *** Block Level ***
  19. Statement
  20. <- KEYWORD_comptime? VarDecl
  21. / KEYWORD_comptime BlockExprStatement
  22. / KEYWORD_nosuspend BlockExprStatement
  23. / KEYWORD_suspend BlockExprStatement
  24. / KEYWORD_defer BlockExprStatement
  25. / KEYWORD_errdefer Payload? BlockExprStatement
  26. / IfStatement
  27. / LabeledStatement
  28. / SwitchExpr
  29. / AssignExpr SEMICOLON
  30. IfStatement
  31. <- IfPrefix BlockExpr ( KEYWORD_else Payload? Statement )?
  32. / IfPrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
  33. LabeledStatement <- BlockLabel? (Block / LoopStatement)
  34. LoopStatement <- KEYWORD_inline? (ForStatement / WhileStatement)
  35. ForStatement
  36. <- ForPrefix BlockExpr ( KEYWORD_else Statement )?
  37. / ForPrefix AssignExpr ( SEMICOLON / KEYWORD_else Statement )
  38. WhileStatement
  39. <- WhilePrefix BlockExpr ( KEYWORD_else Payload? Statement )?
  40. / WhilePrefix AssignExpr ( SEMICOLON / KEYWORD_else Payload? Statement )
  41. BlockExprStatement
  42. <- BlockExpr
  43. / AssignExpr SEMICOLON
  44. BlockExpr <- BlockLabel? Block
  45. # *** Expression Level ***
  46. AssignExpr <- Expr (AssignOp Expr)?
  47. Expr <- BoolOrExpr
  48. BoolOrExpr <- BoolAndExpr (KEYWORD_or BoolAndExpr)*
  49. BoolAndExpr <- CompareExpr (KEYWORD_and CompareExpr)*
  50. CompareExpr <- BitwiseExpr (CompareOp BitwiseExpr)?
  51. BitwiseExpr <- BitShiftExpr (BitwiseOp BitShiftExpr)*
  52. BitShiftExpr <- AdditionExpr (BitShiftOp AdditionExpr)*
  53. AdditionExpr <- MultiplyExpr (AdditionOp MultiplyExpr)*
  54. MultiplyExpr <- PrefixExpr (MultiplyOp PrefixExpr)*
  55. PrefixExpr <- PrefixOp* PrimaryExpr
  56. PrimaryExpr
  57. <- AsmExpr
  58. / IfExpr
  59. / KEYWORD_break BreakLabel? Expr?
  60. / KEYWORD_comptime Expr
  61. / KEYWORD_nosuspend Expr
  62. / KEYWORD_continue BreakLabel?
  63. / KEYWORD_resume Expr
  64. / KEYWORD_return Expr?
  65. / BlockLabel? LoopExpr
  66. / Block
  67. / CurlySuffixExpr
  68. IfExpr <- IfPrefix Expr (KEYWORD_else Payload? Expr)?
  69. Block <- LBRACE Statement* RBRACE
  70. LoopExpr <- KEYWORD_inline? (ForExpr / WhileExpr)
  71. ForExpr <- ForPrefix Expr (KEYWORD_else Expr)?
  72. WhileExpr <- WhilePrefix Expr (KEYWORD_else Payload? Expr)?
  73. CurlySuffixExpr <- TypeExpr InitList?
  74. InitList
  75. <- LBRACE FieldInit (COMMA FieldInit)* COMMA? RBRACE
  76. / LBRACE Expr (COMMA Expr)* COMMA? RBRACE
  77. / LBRACE RBRACE
  78. TypeExpr <- PrefixTypeOp* ErrorUnionExpr
  79. ErrorUnionExpr <- SuffixExpr (EXCLAMATIONMARK TypeExpr)?
  80. SuffixExpr
  81. <- KEYWORD_async PrimaryTypeExpr SuffixOp* FnCallArguments
  82. / PrimaryTypeExpr (SuffixOp / FnCallArguments)*
  83. PrimaryTypeExpr
  84. <- BUILTINIDENTIFIER FnCallArguments
  85. / CHAR_LITERAL
  86. / ContainerDecl
  87. / DOT IDENTIFIER
  88. / DOT InitList
  89. / ErrorSetDecl
  90. / FLOAT
  91. / FnProto
  92. / GroupedExpr
  93. / LabeledTypeExpr
  94. / IDENTIFIER
  95. / IfTypeExpr
  96. / INTEGER
  97. / KEYWORD_comptime TypeExpr
  98. / KEYWORD_error DOT IDENTIFIER
  99. / KEYWORD_anyframe
  100. / KEYWORD_unreachable
  101. / STRINGLITERAL
  102. / SwitchExpr
  103. ContainerDecl <- (KEYWORD_extern / KEYWORD_packed)? ContainerDeclAuto
  104. ErrorSetDecl <- KEYWORD_error LBRACE IdentifierList RBRACE
  105. GroupedExpr <- LPAREN Expr RPAREN
  106. IfTypeExpr <- IfPrefix TypeExpr (KEYWORD_else Payload? TypeExpr)?
  107. LabeledTypeExpr
  108. <- BlockLabel Block
  109. / BlockLabel? LoopTypeExpr
  110. LoopTypeExpr <- KEYWORD_inline? (ForTypeExpr / WhileTypeExpr)
  111. ForTypeExpr <- ForPrefix TypeExpr (KEYWORD_else TypeExpr)?
  112. WhileTypeExpr <- WhilePrefix TypeExpr (KEYWORD_else Payload? TypeExpr)?
  113. SwitchExpr <- KEYWORD_switch LPAREN Expr RPAREN LBRACE SwitchProngList RBRACE
  114. # *** Assembly ***
  115. AsmExpr <- KEYWORD_asm KEYWORD_volatile? LPAREN Expr AsmOutput? RPAREN
  116. AsmOutput <- COLON AsmOutputList AsmInput?
  117. AsmOutputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN (MINUSRARROW TypeExpr / IDENTIFIER) RPAREN
  118. AsmInput <- COLON AsmInputList AsmClobbers?
  119. AsmInputItem <- LBRACKET IDENTIFIER RBRACKET STRINGLITERAL LPAREN Expr RPAREN
  120. AsmClobbers <- COLON StringList
  121. # *** Helper grammar ***
  122. BreakLabel <- COLON IDENTIFIER
  123. BlockLabel <- IDENTIFIER COLON
  124. FieldInit <- DOT IDENTIFIER EQUAL Expr
  125. WhileContinueExpr <- COLON LPAREN AssignExpr RPAREN
  126. LinkSection <- KEYWORD_linksection LPAREN Expr RPAREN
  127. # Fn specific
  128. CallConv <- KEYWORD_callconv LPAREN Expr RPAREN
  129. ParamDecl
  130. <- doc_comment? (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
  131. / DOT3
  132. ParamType
  133. <- KEYWORD_anytype
  134. / TypeExpr
  135. # Control flow prefixes
  136. IfPrefix <- KEYWORD_if LPAREN Expr RPAREN PtrPayload?
  137. WhilePrefix <- KEYWORD_while LPAREN Expr RPAREN PtrPayload? WhileContinueExpr?
  138. ForPrefix <- KEYWORD_for LPAREN Expr RPAREN PtrIndexPayload
  139. # Payloads
  140. Payload <- PIPE IDENTIFIER PIPE
  141. PtrPayload <- PIPE ASTERISK? IDENTIFIER PIPE
  142. PtrIndexPayload <- PIPE ASTERISK? IDENTIFIER (COMMA IDENTIFIER)? PIPE
  143. # Switch specific
  144. SwitchProng <- SwitchCase EQUALRARROW PtrPayload? AssignExpr
  145. SwitchCase
  146. <- SwitchItem (COMMA SwitchItem)* COMMA?
  147. / KEYWORD_else
  148. SwitchItem <- Expr (DOT3 Expr)?
  149. # Operators
  150. AssignOp
  151. <- ASTERISKEQUAL
  152. / SLASHEQUAL
  153. / PERCENTEQUAL
  154. / PLUSEQUAL
  155. / MINUSEQUAL
  156. / LARROW2EQUAL
  157. / RARROW2EQUAL
  158. / AMPERSANDEQUAL
  159. / CARETEQUAL
  160. / PIPEEQUAL
  161. / ASTERISKPERCENTEQUAL
  162. / PLUSPERCENTEQUAL
  163. / MINUSPERCENTEQUAL
  164. / EQUAL
  165. CompareOp
  166. <- EQUALEQUAL
  167. / EXCLAMATIONMARKEQUAL
  168. / LARROW
  169. / RARROW
  170. / LARROWEQUAL
  171. / RARROWEQUAL
  172. BitwiseOp
  173. <- AMPERSAND
  174. / CARET
  175. / PIPE
  176. / KEYWORD_orelse
  177. / KEYWORD_catch Payload?
  178. BitShiftOp
  179. <- LARROW2
  180. / RARROW2
  181. AdditionOp
  182. <- PLUS
  183. / MINUS
  184. / PLUS2
  185. / PLUSPERCENT
  186. / MINUSPERCENT
  187. MultiplyOp
  188. <- PIPE2
  189. / ASTERISK
  190. / SLASH
  191. / PERCENT
  192. / ASTERISK2
  193. / ASTERISKPERCENT
  194. PrefixOp
  195. <- EXCLAMATIONMARK
  196. / MINUS
  197. / TILDE
  198. / MINUSPERCENT
  199. / AMPERSAND
  200. / KEYWORD_try
  201. / KEYWORD_await
  202. PrefixTypeOp
  203. <- QUESTIONMARK
  204. / KEYWORD_anyframe MINUSRARROW
  205. / SliceTypeStart (ByteAlign / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)*
  206. / PtrTypeStart (KEYWORD_align LPAREN Expr (COLON INTEGER COLON INTEGER)? RPAREN / KEYWORD_const / KEYWORD_volatile / KEYWORD_allowzero)*
  207. / ArrayTypeStart
  208. SuffixOp
  209. <- LBRACKET Expr (DOT2 (Expr? (COLON Expr)?)?)? RBRACKET
  210. / DOT IDENTIFIER
  211. / DOTASTERISK
  212. / DOTQUESTIONMARK
  213. FnCallArguments <- LPAREN ExprList RPAREN
  214. # Ptr specific
  215. SliceTypeStart <- LBRACKET (COLON Expr)? RBRACKET
  216. PtrTypeStart
  217. <- ASTERISK
  218. / ASTERISK2
  219. / LBRACKET ASTERISK (LETTERC / COLON Expr)? RBRACKET
  220. ArrayTypeStart <- LBRACKET Expr (COLON Expr)? RBRACKET
  221. # ContainerDecl specific
  222. ContainerDeclAuto <- ContainerDeclType LBRACE container_doc_comment? ContainerMembers RBRACE
  223. ContainerDeclType
  224. <- KEYWORD_struct
  225. / KEYWORD_opaque
  226. / KEYWORD_enum (LPAREN Expr RPAREN)?
  227. / KEYWORD_union (LPAREN (KEYWORD_enum (LPAREN Expr RPAREN)? / Expr) RPAREN)?
  228. # Alignment
  229. ByteAlign <- KEYWORD_align LPAREN Expr RPAREN
  230. # Lists
  231. IdentifierList <- (doc_comment? IDENTIFIER COMMA)* (doc_comment? IDENTIFIER)?
  232. SwitchProngList <- (SwitchProng COMMA)* SwitchProng?
  233. AsmOutputList <- (AsmOutputItem COMMA)* AsmOutputItem?
  234. AsmInputList <- (AsmInputItem COMMA)* AsmInputItem?
  235. StringList <- (STRINGLITERAL COMMA)* STRINGLITERAL?
  236. ParamDeclList <- (ParamDecl COMMA)* ParamDecl?
  237. ExprList <- (Expr COMMA)* Expr?
  238. # *** Tokens ***
  239. eof <- !.
  240. bin <- [01]
  241. bin_ <- '_'? bin
  242. oct <- [0-7]
  243. oct_ <- '_'? oct
  244. hex <- [0-9a-fA-F]
  245. hex_ <- '_'? hex
  246. dec <- [0-9]
  247. dec_ <- '_'? dec
  248. bin_int <- bin bin_*
  249. oct_int <- oct oct_*
  250. dec_int <- dec dec_*
  251. hex_int <- hex hex_*
  252. ox80_oxBF <- [\200-\277]
  253. oxF4 <- '\364'
  254. ox80_ox8F <- [\200-\217]
  255. oxF1_oxF3 <- [\361-\363]
  256. oxF0 <- '\360'
  257. ox90_0xBF <- [\220-\277]
  258. oxEE_oxEF <- [\356-\357]
  259. oxED <- '\355'
  260. ox80_ox9F <- [\200-\237]
  261. oxE1_oxEC <- [\341-\354]
  262. oxE0 <- '\340'
  263. oxA0_oxBF <- [\240-\277]
  264. oxC2_oxDF <- [\302-\337]
  265. # From https://lemire.me/blog/2018/05/09/how-quickly-can-you-check-that-a-string-is-valid-unicode-utf-8/
  266. # First Byte Second Byte Third Byte Fourth Byte
  267. # [0x00,0x7F]
  268. # [0xC2,0xDF] [0x80,0xBF]
  269. # 0xE0 [0xA0,0xBF] [0x80,0xBF]
  270. # [0xE1,0xEC] [0x80,0xBF] [0x80,0xBF]
  271. # 0xED [0x80,0x9F] [0x80,0xBF]
  272. # [0xEE,0xEF] [0x80,0xBF] [0x80,0xBF]
  273. # 0xF0 [0x90,0xBF] [0x80,0xBF] [0x80,0xBF]
  274. # [0xF1,0xF3] [0x80,0xBF] [0x80,0xBF] [0x80,0xBF]
  275. # 0xF4 [0x80,0x8F] [0x80,0xBF] [0x80,0xBF]
  276. mb_utf8_literal <-
  277. oxF4 ox80_ox8F ox80_oxBF ox80_oxBF
  278. / oxF1_oxF3 ox80_oxBF ox80_oxBF ox80_oxBF
  279. / oxF0 ox90_0xBF ox80_oxBF ox80_oxBF
  280. / oxEE_oxEF ox80_oxBF ox80_oxBF
  281. / oxED ox80_ox9F ox80_oxBF
  282. / oxE1_oxEC ox80_oxBF ox80_oxBF
  283. / oxE0 oxA0_oxBF ox80_oxBF
  284. / oxC2_oxDF ox80_oxBF
  285. ascii_char_not_nl_slash_squote <- [\000-\011\013-\046-\050-\133\135-\177]
  286. char_escape
  287. <- "\\x" hex hex
  288. / "\\u{" hex+ "}"
  289. / "\\" [nr\\t'"]
  290. char_char
  291. <- mb_utf8_literal
  292. / char_escape
  293. / ascii_char_not_nl_slash_squote
  294. string_char
  295. <- char_escape
  296. / [^\\"\n]
  297. container_doc_comment <- ('//!' [^\n]* [ \n]*)+
  298. doc_comment <- ('///' [^\n]* [ \n]*)+
  299. line_comment <- '//' ![!/][^\n]* / '////' [^\n]*
  300. line_string <- ("\\\\" [^\n]* [ \n]*)+
  301. skip <- ([ \n] / line_comment)*
  302. CHAR_LITERAL <- "'" char_char "'" skip
  303. FLOAT
  304. <- "0x" hex_int "." hex_int ([pP] [-+]? dec_int)? skip
  305. / dec_int "." dec_int ([eE] [-+]? dec_int)? skip
  306. / "0x" hex_int [pP] [-+]? dec_int skip
  307. / dec_int [eE] [-+]? dec_int skip
  308. INTEGER
  309. <- "0b" bin_int skip
  310. / "0o" oct_int skip
  311. / "0x" hex_int skip
  312. / dec_int skip
  313. STRINGLITERALSINGLE <- "\"" string_char* "\"" skip
  314. STRINGLITERAL
  315. <- STRINGLITERALSINGLE
  316. / (line_string skip)+
  317. IDENTIFIER
  318. <- !keyword [A-Za-z_] [A-Za-z0-9_]* skip
  319. / "@\"" string_char* "\"" skip
  320. BUILTINIDENTIFIER <- "@"[A-Za-z_][A-Za-z0-9_]* skip
  321. AMPERSAND <- '&' ![=] skip
  322. AMPERSANDEQUAL <- '&=' skip
  323. ASTERISK <- '*' ![*%=] skip
  324. ASTERISK2 <- '**' skip
  325. ASTERISKEQUAL <- '*=' skip
  326. ASTERISKPERCENT <- '*%' ![=] skip
  327. ASTERISKPERCENTEQUAL <- '*%=' skip
  328. CARET <- '^' ![=] skip
  329. CARETEQUAL <- '^=' skip
  330. COLON <- ':' skip
  331. COMMA <- ',' skip
  332. DOT <- '.' ![*.?] skip
  333. DOT2 <- '..' ![.] skip
  334. DOT3 <- '...' skip
  335. DOTASTERISK <- '.*' skip
  336. DOTQUESTIONMARK <- '.?' skip
  337. EQUAL <- '=' ![>=] skip
  338. EQUALEQUAL <- '==' skip
  339. EQUALRARROW <- '=>' skip
  340. EXCLAMATIONMARK <- '!' ![=] skip
  341. EXCLAMATIONMARKEQUAL <- '!=' skip
  342. LARROW <- '<' ![<=] skip
  343. LARROW2 <- '<<' ![=] skip
  344. LARROW2EQUAL <- '<<=' skip
  345. LARROWEQUAL <- '<=' skip
  346. LBRACE <- '{' skip
  347. LBRACKET <- '[' skip
  348. LPAREN <- '(' skip
  349. MINUS <- '-' ![%=>] skip
  350. MINUSEQUAL <- '-=' skip
  351. MINUSPERCENT <- '-%' ![=] skip
  352. MINUSPERCENTEQUAL <- '-%=' skip
  353. MINUSRARROW <- '->' skip
  354. PERCENT <- '%' ![=] skip
  355. PERCENTEQUAL <- '%=' skip
  356. PIPE <- '|' ![|=] skip
  357. PIPE2 <- '||' skip
  358. PIPEEQUAL <- '|=' skip
  359. PLUS <- '+' ![%+=] skip
  360. PLUS2 <- '++' skip
  361. PLUSEQUAL <- '+=' skip
  362. PLUSPERCENT <- '+%' ![=] skip
  363. PLUSPERCENTEQUAL <- '+%=' skip
  364. LETTERC <- 'c' skip
  365. QUESTIONMARK <- '?' skip
  366. RARROW <- '>' ![>=] skip
  367. RARROW2 <- '>>' ![=] skip
  368. RARROW2EQUAL <- '>>=' skip
  369. RARROWEQUAL <- '>=' skip
  370. RBRACE <- '}' skip
  371. RBRACKET <- ']' skip
  372. RPAREN <- ')' skip
  373. SEMICOLON <- ';' skip
  374. SLASH <- '/' ![=] skip
  375. SLASHEQUAL <- '/=' skip
  376. TILDE <- '~' skip
  377. end_of_word <- ![a-zA-Z0-9_] skip
  378. KEYWORD_align <- 'align' end_of_word
  379. KEYWORD_allowzero <- 'allowzero' end_of_word
  380. KEYWORD_and <- 'and' end_of_word
  381. KEYWORD_anyframe <- 'anyframe' end_of_word
  382. KEYWORD_anytype <- 'anytype' end_of_word
  383. KEYWORD_asm <- 'asm' end_of_word
  384. KEYWORD_async <- 'async' end_of_word
  385. KEYWORD_await <- 'await' end_of_word
  386. KEYWORD_break <- 'break' end_of_word
  387. KEYWORD_callconv <- 'callconv' end_of_word
  388. KEYWORD_catch <- 'catch' end_of_word
  389. KEYWORD_comptime <- 'comptime' end_of_word
  390. KEYWORD_const <- 'const' end_of_word
  391. KEYWORD_continue <- 'continue' end_of_word
  392. KEYWORD_defer <- 'defer' end_of_word
  393. KEYWORD_else <- 'else' end_of_word
  394. KEYWORD_enum <- 'enum' end_of_word
  395. KEYWORD_errdefer <- 'errdefer' end_of_word
  396. KEYWORD_error <- 'error' end_of_word
  397. KEYWORD_export <- 'export' end_of_word
  398. KEYWORD_extern <- 'extern' end_of_word
  399. KEYWORD_fn <- 'fn' end_of_word
  400. KEYWORD_for <- 'for' end_of_word
  401. KEYWORD_if <- 'if' end_of_word
  402. KEYWORD_inline <- 'inline' end_of_word
  403. KEYWORD_noalias <- 'noalias' end_of_word
  404. KEYWORD_nosuspend <- 'nosuspend' end_of_word
  405. KEYWORD_noinline <- 'noinline' end_of_word
  406. KEYWORD_opaque <- 'opaque' end_of_word
  407. KEYWORD_or <- 'or' end_of_word
  408. KEYWORD_orelse <- 'orelse' end_of_word
  409. KEYWORD_packed <- 'packed' end_of_word
  410. KEYWORD_pub <- 'pub' end_of_word
  411. KEYWORD_resume <- 'resume' end_of_word
  412. KEYWORD_return <- 'return' end_of_word
  413. KEYWORD_linksection <- 'linksection' end_of_word
  414. KEYWORD_struct <- 'struct' end_of_word
  415. KEYWORD_suspend <- 'suspend' end_of_word
  416. KEYWORD_switch <- 'switch' end_of_word
  417. KEYWORD_test <- 'test' end_of_word
  418. KEYWORD_threadlocal <- 'threadlocal' end_of_word
  419. KEYWORD_try <- 'try' end_of_word
  420. KEYWORD_union <- 'union' end_of_word
  421. KEYWORD_unreachable <- 'unreachable' end_of_word
  422. KEYWORD_usingnamespace <- 'usingnamespace' end_of_word
  423. KEYWORD_var <- 'var' end_of_word
  424. KEYWORD_volatile <- 'volatile' end_of_word
  425. KEYWORD_while <- 'while' end_of_word
  426. keyword <- KEYWORD_align / KEYWORD_allowzero / KEYWORD_and / KEYWORD_anyframe
  427. / KEYWORD_anytype / KEYWORD_asm / KEYWORD_async / KEYWORD_await
  428. / KEYWORD_break / KEYWORD_callconv / KEYWORD_catch / KEYWORD_comptime
  429. / KEYWORD_const / KEYWORD_continue / KEYWORD_defer / KEYWORD_else
  430. / KEYWORD_enum / KEYWORD_errdefer / KEYWORD_error / KEYWORD_export
  431. / KEYWORD_extern / KEYWORD_fn / KEYWORD_for / KEYWORD_if
  432. / KEYWORD_inline / KEYWORD_noalias / KEYWORD_nosuspend / KEYWORD_noinline
  433. / KEYWORD_opaque / KEYWORD_or / KEYWORD_orelse / KEYWORD_packed
  434. / KEYWORD_pub / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
  435. / KEYWORD_struct / KEYWORD_suspend / KEYWORD_switch / KEYWORD_test
  436. / KEYWORD_threadlocal / KEYWORD_try / KEYWORD_union / KEYWORD_unreachable
  437. / KEYWORD_usingnamespace / KEYWORD_var / KEYWORD_volatile / KEYWORD_while

Zen

  • Communicate intent precisely.
  • Edge cases matter.
  • Favor reading code over writing code.
  • Only one obvious way to do things.
  • Runtime crashes are better than bugs.
  • Compile errors are better than runtime crashes.
  • Incremental improvements.
  • Avoid local maximums.
  • Reduce the amount one must remember.
  • Focus on code rather than style.
  • Resource allocation may fail; resource deallocation must succeed.
  • Memory is a resource.
  • Together we serve the users.