codemirror / google-modes

A consistent set of modes for C, C++, Java, Go, JavaScript, TypeScript, Python, HTML, and Angular Templates
MIT License
33 stars 28 forks source link

[py] Fixed parsing of extended slices #306

Closed superbobry closed 4 years ago

superbobry commented 4 years ago

Prior to this commit the following failed to parse and as a result affected auto-indentation

for x in xs[i::j]: # <ENTER>

Interestingly, the new tests for slices pass with and without the grammar change because IIUC the variables are correctly tokenized regardless of the surrounding context.

marijnh commented 4 years ago

Thanks! Could you move the repeated expression into the preceding optional ((":" ExprNoComma? (":" ExprNoComma?)?)?) to avoid repeating the check when it doesn't match the first time? Also, please run npm run build-py and include the updated output in the commit.

superbobry commented 4 years ago

Good catch! Done.

I've also added a few more parsing fixes, PTAL.

marijnh commented 4 years ago

Wonderful. Merged!