Open EliotVU opened 5 years ago
Status of marcos in 0.4.3:
Parsing still fails. Sometimes it causes just a small error:
Sometimes a much bigger problem:
The "problems" window is full of
(ANTLR Node Error) ;
Yeah, macros with params are not yet supported, neither are macro symbols being included yet from the global.uci or `include calls.
I was thinking, would it be possible to use the output from make -intermediate
to improve the plugin's macro parsing? Whenever a macro with params occurs, fetch the correct code from the intermediate output, instead of just throwing out the macro. Though I have no idea whether it's possible to keep the source code and intermediate output in sync to be able to programmatically track which parts of the intermediate output are preprocessed macros and which parts correspond to the unprocessed source directly.
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!