[PATCH] D75534: [mlir][Tutorial] Make parsing an empty file print a better error.

Matthias Kramm via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 08:35:02 PST 2020


matthiaskramm created this revision.
matthiaskramm added a reviewer: rriddle.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, mehdi_amini.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75534

Files:
  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
  mlir/test/Examples/Toy/Ch2/empty.toy
  mlir/test/Examples/Toy/Ch3/empty.toy
  mlir/test/Examples/Toy/Ch4/empty.toy
  mlir/test/Examples/Toy/Ch5/empty.toy
  mlir/test/Examples/Toy/Ch6/empty.toy
  mlir/test/Examples/Toy/Ch7/empty.toy

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75534.247916.patch
Type: text/x-patch
Size: 6447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200303/a452550d/attachment.bin>


More information about the llvm-commits mailing list