munificent / craftinginterpreters

Repository for the book "Crafting Interpreters"
http://www.craftinginterpreters.com/
Other
9.07k stars 1.06k forks source link

Enhance Code Readability and Maintainability with Dynamic Indentation Handling #1157

Closed SonDo580 closed 8 months ago

SonDo580 commented 9 months ago

Summary A small enhancement to Jlox's GenerateAST functionality in indentation handling.

Problem In the existing implementation, indentation within printed output was achieved by manually adding spaces before each string.

Solution To address this issue, I introduced an indentation level variable that dynamically controls the number of spaces prefixed to strings during printing. This method allows for consistent and easily adjustable indentation.

munificent commented 8 months ago

Thanks, but I think the current code is OK as it is. Also your reformatting of the file breaks the HTML generator that weaves the code snippets into the book.