Compare commits
2 Commits
e853195cc3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6105f8080d | |||
| bb635f1e94 |
@@ -55,6 +55,40 @@ 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)
|
||||
variables.append(Variable(line[1], 1, 0))
|
||||
return returnval
|
||||
elif keyword == 'string':
|
||||
if len(line) != 4:
|
||||
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]}')
|
||||
else:
|
||||
error(f'Invalid keyword: {line[0]}')
|
||||
|
||||
@@ -6,6 +6,8 @@ Create a string: `string name value bytes`
|
||||
|
||||
Create a boolean: `bool name value`
|
||||
|
||||
Create a boolean from input byte: `booli name byte`
|
||||
|
||||
Create an integer: `int name value`
|
||||
|
||||
**Note**: A string of dynamic length can be created by setting the bytes to -1.
|
||||
|
||||
@@ -1,13 +1,2 @@
|
||||
int num1 796
|
||||
string str1 -1 "Hello, world!"
|
||||
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
|
||||
booli cond 1
|
||||
bool cond2 true
|
||||
Reference in New Issue
Block a user