crypto icon indicating copy to clipboard operation
crypto copied to clipboard

don't allow expressions outside of functions (besides REPL)

Open strattonbrazil opened this issue 7 years ago • 1 comments

Right now if the brightscript runtime executes a file, it will execute every expression it finds outside of a function. This doesn't match the brightscript implementation where expressions must be inside functions.

...
print "running something"

sub Main()
    print "in showChannelSGScreen"
    ...

which raises a syntax error the following error:

Syntax Error. (compile error &h02) in pkg:/source/Main.brs(10)

Should we match the device implementation and look for a main function, or should we enable a flag to toggle it so we can still run expressions in the REPL?

strattonbrazil avatar Nov 29 '18 03:11 strattonbrazil

This is a tough one – node handles it ostensibly by assigning the result of the expression to $_ and printing $_. That won't work in BrightScript because – unlike JavaScript – BrightScript Doesn't support right-associative assignments (e.g. let foo = bar = baz = qux;).

This might require a separate parser entirely, or maybe a separate mode for the parser? Not too sure yet.

sjbarag avatar Dec 04 '18 23:12 sjbarag