[mlir][Tutorial] Make parsing an empty file print a better error.
authorMatthias Kramm <kramm@google.com>
Tue, 3 Mar 2020 21:20:48 +0000 (13:20 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Tue, 3 Mar 2020 21:21:05 +0000 (13:21 -0800)
commitcb530ec8b841b8033032a8bf88d93f7d6df2dbe0
tree95aa5d1bfeca85af40a4ff6455a7a01ac42a388c
parentc10896682d0bb457b9d77fdd753ed9e7e6806db1
[mlir][Tutorial] Make parsing an empty file print a better error.

Summary:
Previously, we would, for an empty file, print the somewhat confusing
  Assertion `tok == curTok [...]' failed.
With this change, we now print
  Parse error [...]: expected 'def' [...]

This only affects the parser from chapters 1-6, since the more advanced
chapter 7 parser is actually able to generate an empty module from an
empty file.  Nonetheless, this commit also adds the additional check to
the chapter 7 parser, for consistency.

Differential Revision: https://reviews.llvm.org/D75534
14 files changed:
mlir/examples/toy/Ch1/include/toy/Parser.h
mlir/examples/toy/Ch2/include/toy/Parser.h
mlir/examples/toy/Ch3/include/toy/Parser.h
mlir/examples/toy/Ch4/include/toy/Parser.h
mlir/examples/toy/Ch5/include/toy/Parser.h
mlir/examples/toy/Ch6/include/toy/Parser.h
mlir/examples/toy/Ch7/include/toy/Parser.h
mlir/test/Examples/Toy/Ch1/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch2/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch3/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch4/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch5/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch6/empty.toy [new file with mode: 0644]
mlir/test/Examples/Toy/Ch7/empty.toy [new file with mode: 0644]