3 ms·
The idea for the TXR extraction language came from simply wanting to do the inverse of what "here document" interpolation does: have some text with variables, a
by kazinator 10y ago
The idea for the TXR extraction language came from simply wanting to do the inverse of what "here document" interpolation does: have some text with variables, and have that match a similar text, binding pieces to the variables. I had a passing familiarity with pattern matching (as in logic programming) without much actual experience using or coding that sort of thing. I wasn't aware of how SNOBOL works, and also wasn't aware of PEGs. I just started implmenting and adding ideas as they occurred to me.
The pattern language is basically equivalent to PEGs, which can be seen from the examples of arithmetic expression and JSON parsing.
When I added functions, and hence recursion, I knew that the matching would increase in theoretical power from just regular languages to context-free. But only when I used it to implement some parsing it hit me that the code is basically just grammar rules that execute. After that when I encountered PEGs in some paper, the material was obvious.
Someone told me some years ago that it reminded them of SNOBOL in some ways. That made me curious, so that I researched SNOBOL a bit.
The directives which capture or assert a chracter or line position might have been influenced by SNOBOL. :)
http://www.nongnu.org/txr/txr-manpage.html#N-02D5D09D http://www.nongnu.org/txr/txr-manpage.html#N-02D5D09D