Category:TXR: Difference between revisions

Content added Content deleted
(Complex example.)
(Just a few blurbs about this language to frame some of this into context.)
Line 3: Line 3:


TXR is a new text extraction language implemented in [[C]], running on [[Linux]] (and possibly other [[POSIX]] platforms).
TXR is a new text extraction language implemented in [[C]], running on [[Linux]] (and possibly other [[POSIX]] platforms).

The source of a TXR query is literal text except for directives and variables preceded by the <code>@</code> character.

Computation evolves by textual pattern matching with implicit backtracking. Non-pattern matching activities are embedded into a pattern matching paradigm. For instance, the line

<pre>Four score and seven years ago,</pre>

is a TXR directive which matches a line of that exact text, or else fails. The following is also a directive:

<lang txr>@(bind foo "abc")</lang>

which succeeds if <code>foo</code> has no prior binding, or already contains <code>"abc"</code>, but fails if <code>foo</code> has a binding to something other than <code>"abc"</code>.

The success of a directive means that computation proceeds to the next directive (and, if this is a pattern match, the input position advances). Failure means that the enclosing query fails, triggering back-tracking behaviors and possibly failure of the entire query.


==Simple Query==
==Simple Query==