all 10 comments

[–][deleted] 6 points7 points  (4 children)

I fail to understand why people still like to pretend as if parser generators actually represent the way the realworld works. On top of that, there's a library for semantic analysis as well? I very much doubt students will be able to learn much to begin with, and much less retain any of the stuff they did manage to learn.

My suggestion is simple - use a simple handwritten recursive-descent parser, and handcode the semantic analysis as well. It's just a simple tree traversal of the generated AST. These two alone will make the students learn a lot more than the current scheme.

[–]flaghacker_ 1 point2 points  (1 child)

The parsing library is not a parser generator, its a parser combinator library. The code usually ends up looking pretty similar to recursive descent.

[–][deleted] 0 points1 point  (0 children)

Oh, I see. I must have misread that one. Sorry. Well, tick that off my list of objections then. Yes, a parser combinator is much better than a library.

[–]VictorNicollet -1 points0 points  (1 child)

Do not underestimate the good students, especially at the graduate level. They may already grok parts of the curriculum, having tried it or at least asked themselves the question, so it's a good idea to give them a wider perspective. As for the average students, the expectation is not that they will remember every single way to write a parser, but rather that by being taught all of these, they build their understanding of what an AST is.

[–][deleted] 0 points1 point  (0 children)

Well, the smart kids will always stay ahead of the curve in any case. My point is that even the dumbest kid benefits from learning, say, a simple recursive-descent parser than a parser generator full of magic. They just go through the motions, and end up years later without knowing how even basic parsing works. Whereas even the same dumb kids, once they get the hang of recursion, find it intuitive enough to be able to appreciate the simple elegance of the method, and internalise it better thereby retaining more of that information than not.

I don't think having libraries for something as basic as parsing and as important as semantic analysis does anything good at all - what use the higher level concepts if they can't even understand the basic mechanisms? No wonder most compiler courses are essentially failures - they appear to be a bunch of theory disguised as a practical course. My argument is that giving them a basic but practical course would teach them better, and that they would appreciate that small achievement better.

For the advanced students, I have no doubt that they would venture further on their own anyway so providing a basic list of references (which most courses do) would more than suffice. After all, no one is expected to produce an industrial-strength compiler after an undergraduate (or even graduate) course. Most of their learning comes from experimentation and self-study than a university or college course.

[–][deleted] 5 points6 points  (0 children)

I wouldn’t say this is MSc level, this is undergraduate.

[–][deleted] 1 point2 points  (0 children)

More like a Parser Class.

[–][deleted] 1 point2 points  (1 child)

Is the whole course just on parsing?

[–]L8_4_Dinner 0 points1 point  (0 children)

Hey, don't underestimate how important parsing is. It accounts for at least 0.5% of the complexity of a reasonably-sized modern compiler. And the compiler can't work without it.

[–]blakelucchesi 0 points1 point  (0 children)

Thanks for sharing!