Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Idiots don't know how to parse...

Name: Cudder !cXCudderUE 2015-11-13 8:45

http://stackoverflow.com/questions/28256/equation-expression-parser-with-precedence

WTF? The accepted answer is from someone who thinks recursive descent is "hard" and a ridiculously bloated parser-generator is "easy"? Pure bisonshit! Almost every real (and toy) compiler uses some variant of recursive-descent. Even GCC, which would probably be the biggest user of Bison, moved to recursive-descent years ago.

These aren't even programmers, these are Java-sipping codemonkeys who know next to nothing about how anything really works and can only parrow "reinventing the wheel" and other "enterprise best practices" bullshit.

Name: Anonymous 2015-12-02 23:28

>>37 has never written a parser. I can tell from having written some parsers myself and from the sheer retardation of her comment.

Come sit on my knee and listen, >>37-chan: you see, the problem when you're parsing a list of function arguments and suddenly encounter "3 + ," is that you encounter the comma when balls deep in the "trying to parse a multiplicand", and at that point you can't say anything more helpful than "I expected a multiplicand or an "(", but got a comma, wtf".

And that's not helpful, my dear >>37. That's not helpful at all, there's not a multiplication operator in sight even, why do you complain about multiplicands? Why are you not helping?

Because to make a helpful error message you got to collect all possibilities from the entire stack trace that got you to that point and weigh them by importance, so that the part where the "+" was expecting something on the right side is more important than what happened deep down below, but also more important than what the "parse a function" expected from that entire list of arguments, or even more so than "parse a program".

And the only way you can do it, my sweet >>37, is by reifying your formal grammar and making a generic parser that can do that figuring out what was expected when a grammar rule failed to apply, and which grammar rule really failed to apply.

*tousles >>37-chan's hair* go play with your legos little one, you are not ready for this.

Name: Anonymous 2015-12-03 0:11

Wtf why does >>38 never talk to me that way? I hate you >>37, I deserved that treatment more than you.

Name: Anonymous 2015-12-03 2:08

Muh dik iz big

Name: Anonymous 2015-12-03 2:44

>>37
I couldn't understand line 1:
What the fuck do you think this is, r/programming?

Name: Anonymous 2015-12-03 8:28

>>37
I agree with >>38, but >>38-sama forgot to also mention that you're a shit-fucking cuntstain who should strangle yourself with your dad's pubes and never touch a keyboard again.

Name: Cudder !cXCudderUE 2015-12-03 9:23

>>38
Bullshit. Generated parsers have horrible errorhandling, so much that you often need to add additional rules just to do it. Nothing quite as simple as RD where you just put the code in the right place. This was one of the main reasons GCC moved to RD from a Bison parser.

But in any case, "X was unexpected here" is usually enough of a clue to the programmer what's wrong.

Name: Anonymous 2015-12-03 13:13

>>43
fuck off namefag

Name: Anonymous 2015-12-03 16:53

/prog/ challenge: write an expression parser with precedence

Name: Anonymous 2015-12-03 17:14

>>40
Thanks

Name: Anonymous 2015-12-03 20:35

>>38
The only tractable way to generate meaningful error messages giving suggested fixes in a non-accusatory tone (I EXPECTED A CLOSING BRACE HERE YOU FUCKING MEATBAG) is to special-case them. By definition you cannot do that generically.
By the way, it makes me hot when you do that.

>>41
A programming languages is a UI too. Treat your users nicely. It's no longer 1989. There's room in your program for a little internal documentation.

Name: Anonymous 2015-12-03 21:11

I was thinking about these pages, but turns out they're about semantic errors rather than syntactic errors. It's still worth caring about this stuff though.
http://elm-lang.org/blog/compiler-errors-for-humans
http://elm-lang.org/blog/compilers-as-assistants

Name: Anonymous 2015-12-04 11:08

>>47
The only tractable way to generate meaningful error messages giving suggested fixes in a non-accusatory tone (I EXPECTED A CLOSING BRACE HERE YOU FUCKING MEATBAG) is to special-case them. By definition you cannot do that generically.

At the very least you can collect _all_ things you could have expected, annotated with human-readable production names and sorted by priority (for example the rule that just consumed a terminal like "+" should be given priority).

Of course you could be doing that in your recursive descent parser too, in an ad-hoc, verbose, and awkward manner. I'm not sure I'd describe it as "tractable".

Name: new meme 2015-12-04 18:59

>>49
Fuck all the way off.

Name: Anonymous 2015-12-05 11:58

>>49
you could be doing that in your recursive descent parser too, in an ad-hoc, verbose, and awkward manner.
You mean with a single extra parameter context[] for each rule? Yeah, so awkward.

Name: Anonymous 2015-12-05 22:16

>>51
That would make compilation SLOW AS BALLS though. Not that it's a bad thing, I'm all for it, though tt might not be feasible in those cases where it actually is the most useful, like compiling a big ``low-level'' language (which might be hard to debug) on a slow embedded device.

Name: Anonymous 2015-12-05 22:37

>>52
Would it? Evidence? I'm going to go out on a limb and say that an additional, explicit stack won't add much overhead.

Name: Cudder !cXCudderUE 2015-12-06 6:42

>>52
The fastest C compiler I know of is TCC. Recursive-descent parser. You're wrong.

Name: Anonymous 2016-07-11 7:15

>>54
faggot
also dubs

Name: Anonymous 2016-08-26 4:50

>>54
What actually makes TCC so fast? GCC is recursive-descent too, isn't it? Yet GCC is a lot slower.

Name: Anonymous 2016-08-26 4:58

>>1
there's a big difference between knowing how to do something and knowing when it's a waste of time.

plenty of compilers you aren't even aware of don't use a hand-written parser, though they may use recursive-descent.

>>56
likely has more to do with the optimizations that gcc does, rather than parsing

Name: Anonymous 2016-08-26 5:05

>>43
i have never used a proper parser generator
nice one bro

Name: Anonymous 2016-08-26 5:06

>>52
doing this thing by hand would make it slower that doing it automatically via parser generator

Name: Anonymous 2016-08-26 6:24

>>56
TCC doesn't optimize much, it has minimal functionality that mimics GCC.

Name: Cudder !cXCudderUE 2016-08-27 14:17

>>56
Because GCC was written by a bunch of GNUtarded academics more interested in the philosophy of software licenses than anything else. RMS wanted to make GCC so convoluted that no one would attempt to modify or extend it, and that's the result. It's not quite enterprisey, but it's a similar attitude that creates other things like their 50-line+ true and false.

It also parses a bunch of other C-ish languages (like C++) in the same code so there are plenty of conditional branches that would always go one way or the other, but the bloat is still there.

>>60
GCC -O0 is still much slower than TCC.

Name: Anonymous 2016-08-27 15:08

C-dder is all talk and no action.

Name: Anonymous 2016-08-27 17:55

Cudder is all talk, and even his talk is shit.

Name: Cudder Internet Defense Force 2016-08-27 18:45

>>63
his

Name: Anonymous 2016-08-27 19:08

WELL FUCK ME IN MY DICKHOLE WITH YOUR 6-INCH CLIT

Name: Anonymous 2016-08-27 19:09

(this space left intentionally androgynous)

Name: Anonymous 2016-08-30 5:35

Check em

Name: sage 2016-08-30 10:42

stop being a namefag

Name: Anonymous 2016-08-30 11:11

>>68
No u

Name: Anonymous 2016-08-30 16:38

>>69
clock quads

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List