3 ms·
Parsing most certainly is *not* easy for someone new to compilers. My students remind me of that all the time.
by azhenley 6y ago
Parsing most certainly is *not* easy for someone new to compilers. My students remind me of that all the time.
- jcranmer 6y agoLexing and parsing probably falls into the category of "obvious once you learn it, mystifying until then." (Although, that said, compiler courses could probably do well to ditch a lot of the LL(1)/LR(1) parsing theory to focus on other topics instead. You still need to teach grammars, and focus a bit on how to actually parse grammars to AST under recursive descent, including expression precedence, but you could probably excise a lot of the parser generator theory.)
- mhh__ 6y agoI know embarrassingly little parser theory - I definitely couldn't write a decent parser generator without looking it up in a book for a few hours - but at least there is a theory: Semantic analysis has lots of mathematical symbology to describe it, doesn't help you write code for the most part.
- marcosdumay 6y agoAs strange as it looks, parser theory is not very relevant on practice for writing parsers. You just use some parser generator or a parser combinators library if your language allows them, and you won't have many problems (except for maybe they being slow). It is way more relevant for optimizing parsers performance and for designing languages syntax.
- vidarh 6y agoAnd when hand-writing parsers, it's fairly common to just use simple recursive descent and all it a day. Anyone can "invent" recursive descent with fairly little prodding about how to divide and conquer.
- mhh__ 6y agoThat's true but it is one and done when you get it working, as opposed to sema which is a constantly changing monster in many languages.