munificent / craftinginterpreters

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

Incorrect code preview in section 8.2.1 variable syntax #1026

Open liangyuanruo opened 2 years ago

liangyuanruo commented 2 years ago

I have a print copy of this wonderful book, it is a work of art. Thank you @munificent for pouring so much time, effort, energy, and your life to create this.

In section 8.2.1 Variable Syntax, the book requests to insert two new lines in generateAst.java. However, the succeeding lines in the preview appear to be incorrect.

// tool/GenerateAst.java in main()
// add "," to previous line
defineAst(outputDir, "Expr", Arrays.asList(
        "Binary     : Expr left, Token operator, Expr right",
        "Grouping   : Expr expression",
        "Literal    : Object value",
        "Variable   : Token name", // <-- for reader to insert
        "Unary      : Token operator, Expr right" // <-- line missing from preview
));
// tool/GenerateAst.java in main()
// add "," to previous line
defineAst(outputDir, "Stmt", Arrays.asList(
        "Expression : Expr expression",
        "Var        : Token name, Expr initializer", // <-- for reader to insert
        "Print      : Expr expression" // <-- line missing from preview
));