[PATCH] D19237: ELF: Add +, -, *, / and & to SECTIONS linker script command.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 08:45:13 PDT 2016


ruiu added a comment.

It uses recursion because the grammar is recursive. Do you find the recursive-descendent parser is hard to read because it uses recursion? Even if your code does not make recursive function calls, you have to handle recursive grammar using some recursive data structure (such as hand-crafted stack rather than call stack.)

Nothing is special in my code, it is a plain operator-precedence parser. If you write a parser for a calculator-ish grammer, and if you don't need a parser tree, then I think that the operator-precedence parser is usually the first choice. It is common technique so readers don't have to take a look at every detail of the code; it can be understood just by reading the comment that this is an operator-precedence grammar, because the implementation is obvious as long as you are familiar with the theory. If we have a reason to create an intermediate representation of an expression, then doing it in your way might make sense, but I think that's not the case.


http://reviews.llvm.org/D19237





More information about the llvm-commits mailing list