User loginNavigation |
archivesRewrite.js – a minimalist s-expr based term rewriting systemRewrite.js is estimated to be a Turing complete, s-expression based term rewriting system. It may be used as a curiosity computing platform, formula application system, proof checker, problem solver, and pretty much anywhere where any kind of computation is required, as long as slower performance on intensive computations doesn't go beyond limits of user patience. Rewrite.js is designed as a creation with only one kind of rules: substitution rules. Being such a minimalist creation, complete rewrite.js implementation fits in a bit more than 400 Javascript lines of code. To get a feeling about rewrite.js appearance, this is a math expression rewriting code in rewrite.js:
(
(
REWRITE
(
MATCH
(VAR <a>)
(RULE (READ <a> + <a>) (WRITE 2 * <a>))
)
(
MATCH
(VAR <a>)
(RULE (READ <a> * <a>) (WRITE <a> ^ 2))
)
)
(x + x) * (x + x)
)
The above example evaluates to:
((2 * x) ^ 2)
Rewrite.js is hosted on https://github.com/contrast-zone/rewrite.js with convenient online playground. Aside from criticism, I'm particularly interested in possible rewrite.js usage ideas. |
Browse archivesActive forum topics |
Recent comments
1 day 3 hours ago
2 days 23 min ago
3 days 5 hours ago
3 days 5 hours ago
1 week 1 day ago
1 week 1 day ago
1 week 1 day ago
4 weeks 1 day ago
5 weeks 7 hours ago
5 weeks 12 hours ago