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.
 
 
 
 

36 lines
1.1 KiB

program = statement, {statement}
block = "{",{statement}, "}"
statement = short_statement | while_block | if_block | function_def | function_bf
short_statement = print | return | input | declaration | assignement | expression | inc-dec | import, ";"
assignement = name, assignement_symbol, expression
declaration = "var" , name , {",",name}
return = "return", expression
import = "import", string
expression = compar_op | function_call
function_call = name, '(',[expression,{','expression,}]
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]
function_def = "def", name, '(',[name,{',',name}],')',block
function_bf = 'bf',name, '{', brainfuck_code, '}'
brainfuck_code = {'<'|'>'|'+'|'-'|'.'|','|'['|']'}
bin_op = "+"|"-"|"*"|"/"|"**"
compar_op = ">"|">="|"<"|"<="|"=="
assignement_symbol = "="|"+="|"-="|"/="|"*="