|
The book says "we propose parsing do subroutineCall statements as if their syntax were do expression".
So I implemented compileDo as follows:
private void compileDo() {
xmlWriter.printStartTag(JackXmlWriter.DO_STATEMENT_TAG_NAME);
process(TokenType.KEYWORD); // 'do'
compileExpression();
process(TokenType.SYMBOL); // ';'
xmlWriter.printEndTag(JackXmlWriter.DO_STATEMENT_TAG_NAME);
}
Which of course, given ExpressionLessSquare/Main.jack, outputs the following XML:
<keyword> do </keyword> <expression> <term> <identifier> game </identifier> <symbol> . </symbol> <identifier> run </identifier> <symbol> ( </symbol> <expressionList> </expressionList> <symbol> ) </symbol> </term> </expression> <symbol> ; </symbol> </doStatement>
But the provided compare file contains:
<doStatement> <keyword> do </keyword> <identifier> game </identifier> <symbol> . </symbol> <identifier> run </identifier> <symbol> ( </symbol> <expressionList> </expressionList> <symbol> ) </symbol> <symbol> ; </symbol> </doStatement>
Have I misinterpreted the point in the book, or is the compare XML file out of sync with the book's advice?
|