• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Rewrite: a pattern matching based programming language

ivan.moony

King Coder
I just reached a decent checkpoint in writing a language which I plan to use in my CMS as a replacement for HTML+CSS+XSLT.

Rewrite bases its functioning on pattern matching against s-expressions and term rewriting. It is a Turing complete minimalist declarative creation where only rules for programming are substitution rules. Entire source code fits in less than 300 javascript lines of code.

this is a rough example code:
Code:
(
    (
        REWRITE
        (
            (READ  (VAR <a>) + (VAR <a>))
            (WRITE 2 * <a>              )
        )
        (
            (READ  (VAR <a>) * (VAR <a>))
            (WRITE <a> ^ 2              )
        )
    )

    (X + X) * (X + X)
)

which results with:
Code:
((2 * X) ^ 2)

I composed a few examples in a browser based playground of which theorem verifying and calculating boolean operations may be the most interesting.

Visit the playground here.
Visit the project homepage here.
 
Last edited:

ivan.moony

King Coder
Just made the array interface more friendly, fixed some bugs and rearranged the examples, one of which is adding two binary numbers. Hope you'll like the new setup.
 
Top