dice = rnd(6): if dice < 2 then
? "You get nothing"
end if
sub _profile(next_line, tm, acc):
t = acc[next_line-1]
if t = invalid then t = 0
acc[next_line-1] = t + tm.TotalMilliseconds()
tm.mark()
end sub
function xml_parse(xml as string):
_ = []: ti = createobject("roTimespan")
_profile(LINE_NUM, ti, _): leafs = []
_profile(LINE_NUM, ti, _): tags = xml.tokenize("<")
_profile(LINE_NUM, ti, _): startN = 0
_profile(LINE_NUM, ti, _): if tags.count() > 0 and left(xml, 1) <> "<" 'line 183
_profile(LINE_NUM, ti, _): startN = 1
_profile(LINE_NUM, ti, _): if tags[0].trim() <> "": 'line 185
_profile(LINE_NUM, ti, _): leafs.push(tags[0])
_profile(LINE_NUM, ti, _): end if
_profile(LINE_NUM, ti, _): end if
...
*** ERROR compiling /pkg:/source/something.brs:
Syntax Error. (compile error &h02) in ...8n/pkg:/source/something.brs(183)
Syntax Error. (compile error &h02) in ...8n/pkg:/source/something.brs(185)
Each line may contain a single statement, or a colon ( : ) may be used to separate multiple statements on a single line.
"TheEndless" wrote:Pray tell, how does that look like a syntax error?
For what it's worth, it just plain looks like a syntax error to me.. 😛
That is some bizarre looking code...
"belltown" wrote:
It's probably just the way the interpreter works. The BrightScript Reference states:Each line may contain a single statement, or a colon ( : ) may be used to separate multiple statements on a single line.
i = 5: for j = 1 to 5- and see that it works. As well as all the other compound statements. Bolding out those words is creative reading, it does not mean only simple statements are allowed.
? i + j
end for
"belltown" wrote:
I think that's because the interpreter considers that FOR is a statement, ? is a statement, and END FOR is a statement, so you have 3 separate statements. There are several references to the "END FOR statement" in the documentation but no references to an "ENDIF statement". ENDIF is part of a multi-line IF statement, and there are no other references in the documentation to any other "multi-line" statements that exist.
i = 1 : while i < 4
? i : i = i + 1
end while
"belltown" wrote:
... although the manual refers to "Block Statements" such as "WHILE-END WHILE", as far as how the BrightScript interpreter operates, I think it's looking at "WHILE condition" as being a separate statement in its own right for parsing purposes, as is "END WHILE" or "ENDWHILE".
...
I'm just postulating that maybe BrightScript (possibly due to its simplistic BASIC origins), may at some level (at least as far as "continuation" is concerned), consider each of the above lines to be a separate "statement".
BrightScript Debugger> for i=1 to 10
A block (such as FOR/NEXT or IF/ENDIF) was not terminated correctly. (compile error &hb5) in $LIVECOMPILE(1190)
BrightScript Debugger> while True
A block (such as FOR/NEXT or IF/ENDIF) was not terminated correctly. (compile error &hb5) in $LIVECOMPILE(1191)
BrightScript Debugger> if True then
A block (such as FOR/NEXT or IF/ENDIF) was not terminated correctly. (compile error &hb5) in $LIVECOMPILE(1192)
BrightScript Debugger> for i=1 to 2: end for: end forThe last one was just to demonstrate that BS interpreter has such a thing as "Syntax Error (runtime error)", which is different from the normal "Syntax Error (compile error)".
Syntax Error. (compile error &h02) in $LIVECOMPILE(1193)
BrightScript Debugger> while False: end while: end while
Syntax Error. (compile error &h02) in $LIVECOMPILE(1194)
BrightScript Debugger> ? "".len
Syntax Error. (runtime error &h02) in $LIVECOMPILE(1167)