Compare commits

...

2 Commits

Author SHA1 Message Date
6105f8080d Booli command 2025-11-06 16:56:21 +11:00
bb635f1e94 Booli command 2025-11-06 15:25:14 +11:00
3 changed files with 39 additions and 13 deletions

View File

@@ -55,6 +55,40 @@ def generateCode(line: list[str], offset: int) -> str:
return '' return ''
else: else:
error(f"Invalid bool: {line[2]}") 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)
variables.append(Variable(line[1], 1, 0))
return returnval
elif keyword == 'string': elif keyword == 'string':
if len(line) != 4: if len(line) != 4:
error(f'String command requires 3 arguments (got {len(line)-1})') error(f'String command requires 3 arguments (got {len(line)-1})')
@@ -385,3 +419,4 @@ def generateCode(line: list[str], offset: int) -> str:
error(f'Invalid argument for end: {line[1]}') error(f'Invalid argument for end: {line[1]}')
else: else:
error(f'Invalid keyword: {line[0]}') error(f'Invalid keyword: {line[0]}')

View File

@@ -6,6 +6,8 @@ Create a string: `string name value bytes`
Create a boolean: `bool name value` Create a boolean: `bool name value`
Create a boolean from input byte: `booli name byte`
Create an integer: `int name value` Create an integer: `int name value`
**Note**: A string of dynamic length can be created by setting the bytes to -1. **Note**: A string of dynamic length can be created by setting the bytes to -1.

View File

@@ -1,13 +1,2 @@
int num1 796 booli cond 1
string str1 -1 "Hello, world!" bool cond2 true
int num2 795
string str2 -1 "World, hello?"
equal num1 num2 cond
if cond
print str1
end if
inc num2
equal num1 num2 cond2
if cond2
print str2
end if