Description
TERM:
IF
TRUE
FALSE
THEN
ELSE
STRING
NOTE:
STRING begins with a quote and ends with the first quote.
Quote is a symbol `"`.
CONDITION:
IF [TRUE | FALSE] THEN
[STRING | CONDITION]
ELSE
[STRING | CONDITION]
NOTE:
It is required to register a pair of IF and ELSE.
Terms in the terms must be separated by at least one space.
Spaces are ` `, \\t, \\v, \\n, \\r, \\f.
EBNF
<condition> = "IF" <space> <boolean> <space>
"THEN" <space>
( <string> | <condition> ) <space>
"ELSE"
( <string> | <condition> ) <space> ;
<bolean> = "TRUE" | "FALSE" ;
<space> = " " | "\\t" | "\\n" | "\\v" | "\\f" | "\\r" ;
<string> = "\\"" { <char> } "\\"" ;
<char> = <utf-8> - "\\""
IDE
IDE.py
Language version starting from Python 3.10+
for condition interpreter.
$ python --version
Python 3.10.4
Packages re
and tkinter
for IDE
$ python IDE.py
or
$ python
>>> from condition_interpreter import ConditionInterpreter
>>> ci = ConditionInterpreter('IF TRUE THEN "Hello, World!" ELSE "Bye, World."')
>>> ci.run()
'"Hello, World!"'
demo 1
run 1