jroesch commented on pull request #5932:
URL: https://github.com/apache/incubator-tvm/pull/5932#issuecomment-651316682
@weberlo I think ANTLR only provides those benefits if you assume the people
working on the project actually know ANTLR, which in so far as I can tell is
not true. Josh and you were pretty much the only ones to work on the previous
parser. Not to mention as we extend the parser to TIR and the rest of TVM it
will become increasingly hard for anyone to make even small tweaks.
The current parser was also incomplete and failed to handle many tricky
cases which can often be solved with small amounts of constant lookahead
tokens.
Furthermore many of the grammar gymnastics required to parse in ANTLR are
complex and easy for new users to break while this might still require some
understanding the ordering is explicit in code for users to read and learn from.
ANTLR is also a painful deployment dependency as we need Java, Python, and
C++ to build the current parser. Furthermore the parser necessitated a rewrite
given that it was in Python and needs to be in C++ or another statically
linkable language.
Finally error reporting the main reason to write it by hand, if you look at
most production quality compilers they have hand written parsers mostly for
error reporting and recovery reasons. Most generated parsers fail on the first
invalid token, or parse issue such as an invalid identifier. The above parser
can continue even after encountering a parse error enabling better error
reporting.
In my exp. compilers which use parser generators i.e OCaml or F* have a
horrible user exp. when compared to languages with hand rolled parsers such as
Rust or Lean.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]