Custom literals in Pike code?
Chris Angelico <[email protected]>
| Newsgroups | gmane.comp.lang.pike.user |
|---|---|
| Message-ID | <CAPTjJmq9bPT1C=bu5FLs=UXiRN2tuoF8_=U4UTVA+rce1PBDrQ@mail.gmail.com> |
I have a crazy idea that I'm wondering how to implement... any suggestions welcomed! TinyFugue offered a special form of integer literal which looks like a time value - so, for instance, 1:23:45 is equal to (1*3600+23*60+45) or 5025. I'd like to be able to do this in my own expression evaluator, but ideally, I'd also like to let Pike do most of the actual expression evaluation work. (Currently, it just compiles up a wrapper with the provided text inside it, similarly to Hilfe's method.) Is there a way to hook into the parser and create a modified grammar? Performance isn't a big issue here, as it's intended for interactive use. Currently: > /x tm(5025) 01:23:45 > /x tm(5025)+15 01:24:00 Ideally: > /x 1:23:45 01:23:45 > /x 1:23:45+15 01:24:00 Any ideas? ChrisA