Skip to main content

Module lua

Module lua 

Source
Expand description

Rendering the Lua CST. Spec §5.

Two spaces per level. Lua has no gofmt and no formatter a generated file has to agree with, so the width is chosen for the content this column produces: a type descriptor is a table of tables of tables, and at four spaces the innermost member sits past column sixty before its first key.

Nothing is decided here. There is one layout rule and it reads off the node in hand: a table is written on one line when no entry carries a comment and no entry’s value is itself a table. Nothing is lost either way — the same entries in the same order — and a renderer that had to be told which form to use would be carrying a decision the tree could not show.

§Two comment markers, and they are not interchangeable

-- is read by nothing. --- is read by lua-language-server, which attaches the block to the declaration that follows it. So zerodds_lang_cst::lua::Stat::Comment renders with -- and zerodds_lang_cst::lua::Stat::Annotation with ---, and the file header renders with -- because there is no declaration it is about. Neither is read by the Lua runtime.

Functions§

escape_string
Escape a string for a Lua double-quoted literal.
expr
Render one expression, for a caller that has only one.
file
Render a whole file.
ident
The identifier a name renders as, for a caller assembling one.
stat
Render one statement, for a caller that has only one.