HTPL Compiler
  • HTPL Compiler
  • Introduction
  • Github repository
  • What is HTPL and why it exists
  • Getting started
  • Syntax
    • Variable declaration
    • Returning values
    • Operations between values
    • Value assignment
    • If then else branches
    • Comparison and logical operators
    • Function declaration and invocation
    • While loop
    • Inputs and outputs
    • Comments
  • Other
    • HTPLCompiler interface - Browser
    • Error handling
Powered by GitBook
On this page

Was this helpful?

  1. Syntax

Comparison and logical operators

As seen previously, a comparison is identified by the <strong> element. The operator is specified by the id. Exactly two children are required, both of them must return a comparable value:

<strong id=">=">
    <p id="foo"></p>
    <p id="10"></p>
</strong>
<strong id="!=">
    <p id="foo"></p>
    <p>Hello there!</p>
</strong>

is compiled as:

foo >= 10;
foo != 'Hello there!';

<strong> comparison can be chained with <and>, <or> and <not> logical operations to make more complex conditions. Both <and>, <or> require exactly two children, while <not> requires only one child:

<or>
    <and>
        <strong id=">=">
            <p id="foo"></p>
            <p id="10"></p>
        </strong>
        <strong id="==">
            <p id="phrase"></p>
            <p>Hello there!</p>
        </strong>
    </and>
    <not>
        <strong id="==">
            <p id="reply"></p>
            <p>General Kenobi</p>
        </strong>
    </not>
</or>

is compiled as:

(((foo >= 10) && (phrase == 'Hello there!')) || (!(reply == 'General Kenobi')))

This comparisons can be inserted as first child of <ul> elements to create complex if conditions

PreviousIf then else branchesNextFunction declaration and invocation

Last updated 4 years ago

Was this helpful?