UnrealScript-Language-Service icon indicating copy to clipboard operation
UnrealScript-Language-Service copied to clipboard

Preprocessor macros

Open EliotVU opened this issue 4 years ago • 3 comments

The usage of macros can lead to severe parsing and indexing issues, like the following code:

return ( `TimeSince( LastRenderTime ) < 0.3 );

The usage of `TimeSince here will tell the lexer that this is a PP command, when this is occurred the input will be thrown out thus leaving the parser with:

return ( < 0.3 );

Which leads to even bigger issues down the road, so as the end block of a method not being terminated.

One workaround for this issue could be to safely parse binary operators that are missing an expression on the left or right, however due the nature of UnrealScript allowance of custom defined pre and post operators, "< 0.3" could in theory be a post operator! Thus it cannot be assumed to be an incomplete binary operator (albeit it would be totally unexpected for "<" symbol, that cannot be said of other symbols).

The proper solution would be not to skip any PP commands and instead fully parse and evaluate any macro prior to parsing the document, this is however not an easy task!

EliotVU avatar Jul 30 '19 15:07 EliotVU