You can now return a constant string

Rather than having to store it as a variable
This commit is contained in:
Johan B.W. de Vries 2025-02-09 15:03:11 +01:00
parent 5fa042c5cd
commit a184d4c5e3
4 changed files with 33 additions and 3 deletions

View File

@ -162,7 +162,10 @@ def parsestatreturn(indent):
emit('return ')
if ' ' == peek():
skip()
parseexprvarref()
if quote == peek():
parseconststring()
else:
parseexprvarref()
emit(eol)
skipchar(eol)

View File

@ -151,7 +151,15 @@ parsestatreturn indent:
calc isspace eq char " "
if isspace
skip
parseexprvarref
calc char peek
calc isquote eq char quote
calc isnotquote not isquote
if isquote
parseconststring
/
if isnotquote
parseexprvarref
/
/
emit eol
skipchar eol

View File

@ -195,6 +195,8 @@ parsestatbreak indent:
parsestatreturn indent:
declare char
declare isspace
declare isnotquote
declare isquote
declare isnotspace
emit indent
emit "return "
@ -203,7 +205,15 @@ parsestatreturn indent:
calc isnotspace not isspace
if isspace
skip
parseexprvarref
calc char peek
calc isquote eq char quote
calc isnotquote not isquote
if isquote
parseconststring
/
if isnotquote
parseexprvarref
/
/
if isnotspace
emit "0"

View File

@ -0,0 +1,9 @@
func:
return "Success"
/
main:
declare result
calc result func
emit result
/