Hacker News new | past | comments | ask | show | jobs | submit login

My experience is that splitting lexing and parsing is by far the norm, even in recursive descent.



Oh, thank you! I was wondering if I was an outlier.


Nah, I’ve been toying with writing a compiler and that’s where I’ve gotten to too, it seems to my inexperienced self at least, if what you’re implementing is a specified language, combining the phases makes sense since you only have one thing per language, but while making a language and experimenting, having them be separate helps reduce a lot of complexity in the parser for things like tokens that go across multiple lines.

I have no idea if the above observations are generally true, but that’s been my experience with the handful of parsers I’ve thrown away because they get too unwieldy for what I want.


Funny; my experience is the opposite.

My first production-quality parser was for the `bc` language, which is specified in a standard.

But your experience is just as valid as mine.


I know right?

I had a friend in college who nearly always solved problems 'backwards' to everyone else cause it's just how her brain worked, like we'd do a standard for(int i = 0; i < length; i++) and she'd have for(int i = length; i >=0; i--) kinda backwards.

I don't question it at this point anymore and just marvel at the mathematical validity of it all.


It's buggy though


It definitely can be, and it was mostly an illustrative example for the ‘mathematical validity’ part of my comment. When you’re just starting out, working valid code is better than nothing!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: