Booli command
This commit is contained in:
@@ -55,6 +55,39 @@ def generateCode(line: list[str], offset: int) -> str:
|
||||
return ''
|
||||
else:
|
||||
error(f"Invalid bool: {line[2]}")
|
||||
elif keyword == 'booli':
|
||||
if len(line) != 3:
|
||||
error(f'Booli command requires 2 arguments (got {len(line)-1})')
|
||||
warn('Booli command not yet implemented.')
|
||||
try:
|
||||
idx = int(line[2])
|
||||
if idx < 0:
|
||||
error(f'Invalid input index: \'{line[2]}\'')
|
||||
except ValueError:
|
||||
error(f'Invalid input index: \'{line[2]}\'')
|
||||
quit()
|
||||
returnval = '>' * (offset + idx) + '[' + '<' * idx + '<+<+>>' + '>' * idx + '-]'
|
||||
returnval += '<' * idx + '<[->' + '>' * idx + '+' + '<' * idx + '<]<'
|
||||
|
||||
returnval += '[->>[>]'
|
||||
for var in variables:
|
||||
if var.bytes >= 0:
|
||||
returnval += '>' * (var.bytes+1)
|
||||
elif var.bytes == -1:
|
||||
returnval += '>[>]'
|
||||
else:
|
||||
error()
|
||||
returnval += '>+<'
|
||||
for var in reversed(variables):
|
||||
if var.bytes >= 0:
|
||||
returnval += '<' * (var.bytes+1)
|
||||
elif var.bytes == -1:
|
||||
returnval += '<[<]'
|
||||
else:
|
||||
error()
|
||||
returnval += '<[<]<]'
|
||||
returnval += '<' * (offset-2)
|
||||
return returnval
|
||||
elif keyword == 'string':
|
||||
if len(line) != 4:
|
||||
error(f'String command requires 3 arguments (got {len(line)-1})')
|
||||
@@ -385,3 +418,4 @@ def generateCode(line: list[str], offset: int) -> str:
|
||||
error(f'Invalid argument for end: {line[1]}')
|
||||
else:
|
||||
error(f'Invalid keyword: {line[0]}')
|
||||
|
||||
Reference in New Issue
Block a user