This repository contains simple programming language with parser, interpreter and code analyzer. The language includes basic constructs such as conditional and print statements, variable assignment and logical expressions.
The syntax for the if
statement is as follows,
if:<condition>then:
<statements>
else:
<statements>
end
where
<condition>
represents a boolean expression which contains operators such as<
,&&
, boolean variables etc.<statements>
could be one or more statements e.g print, variable assignment or other if statements. Make sure there are no tabs between the if-else construction and the statements. Line breaks are also required, as they appeared on the code-syntax block.
The syntax for variable assignments is as follows,
<variableName>=<expression>
where
<variableName>
is the name of the variable. It can only be a sequence of lowercase letters.<expression>
one of the available logical or arithmetic expressions.
The syntax for the print
statement is as follows,
print:<expression>
where
<expression>
one of the available logical or arithmetic expressions.
Logical expressions can be used in every statement. The supported operators are:
==
equal<
less than>
greater than<=
less than or equal>=
greater than or equal!=
inequality&&
logical and||
logical or
Arithmetic expressions can be used in every statement. The supported operators are:
+
addition*
multiplication
Here are some examples of code written in this language:
if:true>falsethen:
x=true
print:x<false
else:
x=true
if:x==truethen:
x=true
else:
x=true
end
print:true
x=true
end
x=3+4+5
print:true&&false<true||false
- Make sure you do not add line breaks at the beginning of the text document.
- If you use reserved variable names, such as print, the behaviour of the program may be unpredictable. Try not to use them at all.
- Clone source repository to your remote.
- Add desired code to a new text file or to an F# variable.
- And then call
evaluateProgram
function fromSimpleLanguage.Main
.
To find more building and running options take a look at the MiniScaffold template.