CCodeBuilder class
Defined in module l0_c_emitter (l0_c_emitter.py).
Helper for building C code with indentation tracking.
Public static attributes
- static List lines
- static int indent_level
- static str indent_str
Public functions
- auto indent(self) -> None
- Increase the indentation level.
- auto dedent(self) -> None
- Decrease the indentation level.
- auto emit(self, str line = "") -> None
- Emit a line with current indentation.
- auto emit_raw(self, str line) -> None
- Emit a line without indentation.
- auto to_string(self) -> str
- Combine all lines into a single string.
Public attributes
Function documentation
None l0_c_emitter:: CCodeBuilder:: dedent(self)
Decrease the indentation level.
| Exceptions | |
|---|---|
| AssertionError | If indentation level is already zero. |
None l0_c_emitter:: CCodeBuilder:: emit(self,
str line = "")
Emit a line with current indentation.
| Parameters | |
|---|---|
| line | The C code line to emit. If empty, emits a blank line. |
None l0_c_emitter:: CCodeBuilder:: emit_raw(self,
str line)
Emit a line without indentation.
| Parameters | |
|---|---|
| line | The C code line to emit directly. |
str l0_c_emitter:: CCodeBuilder:: to_string(self)
Combine all lines into a single string.
| Returns | The complete C source code string with a trailing newline. |
|---|