Open tomasohara opened 1 year ago
Would it not be a better use of your time to implement parsing of array assignment?
That's something I wouldn't feel comfortable doing. Adding unimplemented nodes is straightforward as the internals of the span are ignored. Moreover, the bar for success is lower so to speak, because the alternative is an exception.
My current testing over the bash test suite shows that the following results:
Configuration # Exceptions Percent
default 110 41%
unimplemented 99 37%
"" w/ arrays 78 29%
This uses the 268 .test and .sub scripts in the bash tests directory for the bashlex version: 4.3.22(2).
I'm hoping to get the exceptions down to less than 10% because I'm using bashlex in a bash-to-python translator, although currently just for sanity checks.
Fair enough.
My concern is deviation from the bash C implementation. Adding custom code to bashlex would make adding the missing functionality from bash harder.
But I'd like to unblock you, so please send a pull request.
It would be good for array assignments to flagged as unimplemented when the new proceedonerror flag is enabled. This way, a complete AST can still be generated.
Currently, array assignment leads to a parsing error:
It would be better to add an unimplemented node to the AST:
This can be implemented as follows (see attachment for complete diff):
unimplemented-array-node-diff.txt
I can work this into a pull request if desired. I wasn't quite sure of the best way to handle the flags, so suggestions would be welcome. For example, I was going to use parser flags, but they seemed more related to internal state than final attribute.