An interpreter for brainfuck, and a compiler from a minimal C-like language to brainfuck.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
749 B

program = statement, {statement}
block = "{",{statement}, "}"
statement = short_statement | while_block | if_block
short_statement = declaration | assignement | expression | inc-dec, ";"
assignement = name, assignement_symbol, expression
declaration = "var" , name , {",",name}, ";"
expression = compar
compar = calcul, [compar_op, calcul]
calcul = terme, [('+'|'-'), terme]
terme = factor [("*"|"/"), factor]
factor = val ["**", val]
val = name | number | "(", expression, ")"
inc-dec = name, ("++" | "--")
condition = '(', expression, ')'
while_block = "while", condition, block
if_block = "if", condition, block, ["else", block]
bin_op = "+"|"-"|"*"|"/"|"**"
compar_op = ">"|">="|"<"|"<="|"=="
assignement_symbol = "="|"+="|"-="|"/="|"*="