Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> $ /usr/bin/ruby -e 'puts % hello + "world"'

Yes, it's roughly limited in use to places where it is not ambiguous whether it would be the start of a quoted string or the modulus operator, and after a method name would be ambiguous.

> but, at the intersection is "ruby parsing is the 15th circle of hell"

It's surprisingly (not this part, anyway) not that hard. You "just" need to create a forward reference, and keep track of heredocs in your parser, and when you come to the end of a line with heredocs pending, you need to parse them and assign them to the variable references you've created.

It is dirty, though, and there are so many dark corners of parsing Ruby. Having written a partial Ruby parser, and being a fan of Wirth-style grammar simplicity while enjoying using Ruby is a dark, horrible place to live in. On the one hand, I find Ruby a great pleasure to use, on the other hand, the parser-writer in me wants to spend eternity screaming into the void in pain.



How are you so awesome?


Thanks. I'm a big fan of your work, so that is appreciated...




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

Search: