Skip to content

Issues in Chapter 3 #208

@Ajorian

Description

@Ajorian
  1. On page 32, while defining the first draft of a Lark grammar for Lint language, stmt is not defined.
  2. On the bottom of the page 32, assuming that stmt is defined as stmt: "print" "(" exp ")" | exp, the parsed result for the input 1+3 in invalid. Actually, the generated tree does not contain any stmt_list Tree object. It must be some thing like:

Tree('lang_int', [Tree('stmt_list', [Tree('stmt', [Tree('exp', [Tree('exp', [Token('INT', '1')]), Tree('exp', [Token('INT', '3')])])]), Token('NEWLINE', '\n'), Tree('stmt_list', [])])])
3. The grammar in Figure 3.3 does not accept single line programs such as ‘1+2’ while ‘1+2\n’ is acceptable. To accept single line programs we the grammar must be updated as follows:

stmt_list:
| stmt NEWLINE stmt_list -> add_stmt
| stmt -> single_line
  1. In section 3.5 the last sentence of the second paragraph "A dotted rule is simply a grammar rule with a period indicating how much of its
    right-hand side has already been parsed" must be modified to "... how much of its left-hand side has already been parsed. Also, in the next sentence "... an exp followed by + but has not yet parsed an exp to the right of +." must be "... an exp followed by + but has not yet parsed an exp_hi to the right of +."
  2. On the bottom of the page 41 in the second pullet point, the sentence "If there there is a shift edge ..." one "there" is extra.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions