Thue (programming language)
From Wikipedia, the free encyclopedia
Thue (pronounced "TOO-ay") is an esoteric programming language invented by John Colagioia in early 2000. It is a meta-language that can be used to define or recognize Type-0 languages from the Chomsky hierarchy. Because it is able to define languages of such complexity, it is also Turing-complete itself. Thue is based on a nondeterministic string rewriting system called semi-Thue grammar, which itself is named after (and possibly created by) the Norwegian mathematician Axel Thue; inspiration is also taken from the grue. The author describes it as follows: "Thue represents one of the simplest possible ways to construe constraint-based programming. It is to the constraint-based paradigm what languages like OISC are to the imperative paradigm; in other words, it's a tar pit."
Contents |
[edit] Production Rules
A Thue program starts with substitution rules of the form
- lhs ::= rhs
Successive rules can be added. The rulebase terminates with a lone production symbol on a line. The initial state is a series of symbols which follow the rulebase.
Thue consumes the initial symbols and substitutes the result of the rules for each of the initial state's symbols.
Thue terminates when lhs cannot be found in a resultant state.
[edit] Notes
- ::= is pronounced can be.
- lhs is "left hand side".
- rhs is "right hand side".
- "::=" can never be the lhs.
- ":::" is an input stream.
- "~" is the output stream.
- Semi-Thue systems are isomorphic to unrestricted grammars.
[edit] Calling Thue
When invoked with 'd' (debug), print the state. When invoked with 'l' (left side), apply the rules left-to-right. When invoked with 'r' (right side), apply the rules right-to-left. The last 'l' or 'r' overrides the previous switches.