SPBU 3rd semester homework assignment.
Definition using EBNF notation:
[x]
denotes one or more
{x}
denotes zero or more
(x)
denotes a capture group
digit = "1" | ... | "9"
number = { digit }
letter = "a" | ... | "z" | "A" | ... | "Z"
identifier = letter { letter | digit }
factor = identifier | number | ifExpression | (factor "*" factor)
add = factor | (add "+" add)
arithmeticExpression = factor | add
booleanValue = "true" | "false"
relationalOperator = "=" | "<>" | "<=" | "<" | ">=" | ">"
booleanExpression = booleanValue | (arithmeticExpression | identifier) relationalOperator (arithmeticExpression | identifier)
ifExpression = "if" "(" booleanExpression ")" "then"
"(" [ arithmeticExpression | booleanExpression | ifExpression ] ")"
"else"
"(" [ arithmeticExpression | booleanExpression | ifExpression ] ")"
command = "print:" (arithmeticExpression | identifier)
assignment = identifier "=" (booleanValue | arithmeticExpression | identifier | ifExpression)
statement = assignment | command
program = {statement}
To get a local copy up and running follow the steps below.
-
Clone the repo:
git clone https://github.com/artem-burashnikov/SimpleParser.git
-
Build the project:
./build.sh
CLI is available:
USAGE: SimpleParser [--help] <path>
FILEPATH:
<path> Specify a path to the file
containing a program.
OPTIONS:
--help Display this list of options.
Following a language definition, a simple program may look like this:
x=3
y=2
z=if(true)then(x*y+7)else(1)
print:z
Outputs 13
to the console.
Distributed under the MIT License. See LICENSE for more information.