Skip to main content

Crate yog_codegen

Crate yog_codegen 

Source
Expand description

The toolkit Yog’s code generators are written with — what holds in any language: the traits a language implements to be generated (Comments, Literals, Identifiers, Blocks), names in each case, quoting by a language’s escapes, the header every generated file opens with, an indenting writer, and writes that leave unchanged files be. The languages themselves are their own crates (yog-codegen-java, …).

Modules§

quote
Quoting text as a literal, by a language’s own escapes.

Structs§

Code
Generated code of language L, written a line at a time at the current depth.
Header
A generated file’s header.

Enums§

Regenerate
How a generated file is written again.

Traits§

Blocks
How the language nests: its blocks and their indentation.
Comments
How the language writes comments.
Identifiers
The language’s names: its reserved words, and how a name spelled like one is made an identifier.
Literals
How the language writes string literals.

Functions§

camel
stat_bar / StatBar → statBar.
pascal
stat_bar / stat-bar / statBar → StatBar.
screaming
statBar / stat_bar → STAT_BAR.
snake
StatBar / stat-bar → stat_bar.
words
The words of a name: split at separators (_ - / . space) and before each capital (statBar, StatBar, stat_bar, stat-bar → stat, bar as written: stat, Bar).
write_if_changed
Writes code to path (creating its directory) unless it’s already there: unchanged files keep their mtime, so builds don’t redo work. Whether it wrote.