Skip to content

transforms the HTML markup language into a full working turing complete programming language

License

Notifications You must be signed in to change notification settings

Catalyn45/chtml

Repository files navigation

CHTML

This is a transpiler which transforms the HTML markup language into a full working turing complete programming language.

How to use

python ./main.py <input_html_name> <output_binary_name>

example:
python ./main.py ./programs/fibonacci.html output

Documentation

As a generale rule, the id property is considered the identifier and class property is considered the type.

Minimal program:

<html>
    <head></head>
    <body>
        <div id="main" class="int">
        </div>
    </body>
</html>

Primitives:

numbers

<p>10</p>

strings

<p>"hello"</p>

Expressions

Add 10 and 20

<h1>
    <p>10</p>
    <p>20</p>
</h1>

Subtract 10 from 20

<h2>
    <p>20</p>
    <p>10</p>
</h2>

Multiply 10 and 20

<h3>
    <p>10</p>
    <p>20</p>
</h3>

Divide 20 by 10

<h4>
    <p>20</p>
    <p>10</p>
</h4>

Add variable a and 10

<h1>
    <link href="a">
    <p>10</p>
</h1>

Check if a and b are true

<h5>
    <link href="a">
    <link href="b">
</h5>

Check if a or b are true

<h6>
    <link href="a">
    <link href="b">
</h6>

Not a

<u>
    <link href="a">
</u>

Check if a equals b

<i>
    <link href="a">
    <link href="b">
</i>

Check if a is less than b

<b>
    <link href="a">
    <link href="b">
</b>

Check if a is greater than b

<strong>
    <link href="a">
    <link href="b">
</strong>

Call function fibonacci with argument 5

<ul id="fibonacci">
    <li><p>5</p></li>
</ul>

Statements

create a new variable a of type int which will be initializated with 10.

<span id="a" class="int">
    <p>10</p>
</span>

change the value of variable a to 20 ( we don't use the class property)

<span id="a">
    <p>20</p>
</span>

create an if statement. the thead is the condition for the if statement, tbody are the statements if the for the true branch and tfoot the statements for the false branch.

<table>
    <thead>
        <b>
            <link href="a">
            <p>20</p>
        </b>
    <thead>
    <tbody>
        <ul id="print">
            <li><p>"success"</p></li>
        </ul>
    </tbody>
    <tfoot>
        <ul id="print">
            <li><p>"failure"</p></li>
        </ul>
    </tfoot>
</table>

create an infinite loop with textarea, and use the hr to break from the loop

<textarea>
    <table>
        <thead>
            <b>
                <link href="a">
                <p>0<p>
            </b>
        <thead>

        <tbody>
            <hr>
        </tbody>
    </table>
<textarea>

Functions

Create a new function named fibonacci which will return an int

<div id="fibonacci" class="int">
</div>

Parameters

Fibonacci function will receive a parameter of type int identified n. The parameters declaration location doesn't need to be at the begining of the function

<div id="fibonacci" class="int">
    <ol>
        <li class="int">n</li>
    </ol>
</div>

Return

Fibonacci function will return the number 10

<div id="fibonacci" class="int">
    <a>
        <p>10</p>
    </a>
</div>

About

transforms the HTML markup language into a full working turing complete programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published