You can now return a constant string
Rather than having to store it as a variable
This commit is contained in:
parent
5fa042c5cd
commit
a184d4c5e3
@ -162,6 +162,9 @@ def parsestatreturn(indent):
|
||||
emit('return ')
|
||||
if ' ' == peek():
|
||||
skip()
|
||||
if quote == peek():
|
||||
parseconststring()
|
||||
else:
|
||||
parseexprvarref()
|
||||
emit(eol)
|
||||
skipchar(eol)
|
||||
|
||||
@ -151,8 +151,16 @@ parsestatreturn indent:
|
||||
calc isspace eq char " "
|
||||
if isspace
|
||||
skip
|
||||
calc char peek
|
||||
calc isquote eq char quote
|
||||
calc isnotquote not isquote
|
||||
if isquote
|
||||
parseconststring
|
||||
/
|
||||
if isnotquote
|
||||
parseexprvarref
|
||||
/
|
||||
/
|
||||
emit eol
|
||||
skipchar eol
|
||||
/
|
||||
|
||||
@ -195,6 +195,8 @@ parsestatbreak indent:
|
||||
parsestatreturn indent:
|
||||
declare char
|
||||
declare isspace
|
||||
declare isnotquote
|
||||
declare isquote
|
||||
declare isnotspace
|
||||
emit indent
|
||||
emit "return "
|
||||
@ -203,8 +205,16 @@ parsestatreturn indent:
|
||||
calc isnotspace not isspace
|
||||
if isspace
|
||||
skip
|
||||
calc char peek
|
||||
calc isquote eq char quote
|
||||
calc isnotquote not isquote
|
||||
if isquote
|
||||
parseconststring
|
||||
/
|
||||
if isnotquote
|
||||
parseexprvarref
|
||||
/
|
||||
/
|
||||
if isnotspace
|
||||
emit "0"
|
||||
/
|
||||
|
||||
9
tests/flowreturnvalueconstant.lang0
Normal file
9
tests/flowreturnvalueconstant.lang0
Normal file
@ -0,0 +1,9 @@
|
||||
func:
|
||||
return "Success"
|
||||
/
|
||||
|
||||
main:
|
||||
declare result
|
||||
calc result func
|
||||
emit result
|
||||
/
|
||||
Loading…
x
Reference in New Issue
Block a user