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