rokucommunity / brighterscript

A superset of Roku's BrightScript language
MIT License
153 stars 47 forks source link

Adds Conditional Compilation Statements to the AST #1149

Closed markwpearce closed 2 months ago

markwpearce commented 3 months ago

Conditional compile directives (#if, #const, #error, etc.) are now part of the AST, and as such, the branches of the condition compiles can be walked.

There is one concession with this: #if blocks are treated as any other block, and everything in them must be self contained, or will cause a diagnostic.

That means that even though this is allowed in Brightscript:

sub foo()
# if true
end sub
#end if

it will cause some diagnostics, because the sub foo() is partially inside and outside the #if statement

Addresses #1023

markwpearce commented 2 months ago

I suppose we should support #if not <bs_const> as well? #1158

TwitchBronBron commented 2 months ago

I suppose we should support #if not <bs_const> as well? #1158

Yes, if we can!