p5.js
p5.js copied to clipboard
Make reserved word assignment regex work better with function calls
Resolves https://github.com/processing/p5.js/issues/5734
Changes:
- Made the assignment statement regex a little bigger to handle more edge cases:
- Instead of splitting on all commas, it uses a regex to parse the whole list of assignments
- It will now correctly parse single-level function calls and ignore them
- It will stop parsing after anything it doesn't match so that it doesn't introduce new false positives
- It still uses regexes instead of writing a simple recursive parser to avoid complexity/bugs
- Added tests to make sure function parameters on right hand sides of assignments are ignored
PR Checklist
- [x]
npm run lintpasses - [x] [Inline documentation] is included / updated
- [x] [Unit tests] are included / updated
Pretty complex regex there that took some time to wrap my head around. If we didn't miss anything obvious it should be good enough for now. Thanks!
Thanks @davepagurek and @limzykenneth ✨