Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix array access priority in PowerShell lexer #1429

Merged
merged 3 commits into from Feb 11, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Feb 5, 2020

The PowerShell lexer expects the text .identifier to be followed by parameters. This is not always the case as in the case where the text is .identifier['key']. This creates a new rule for handling this case.

This fixes #1407.

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Feb 5, 2020
@pyrmont pyrmont self-assigned this Feb 5, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Feb 5, 2020

@flipcc I initially thought the problem was in the :dq state but after going through the example you provided more closely, I realised that the issue was the lexer getting stuck in the :parameters state. This was happening because the lexer was treating .Properties as being a function that it expected to be followed by parameters.

I'm not terribly happy with my solution. It feels a bit like a band-aid but what do you think? In your example, what is Properties? Is it a function? Is Properties['sn'] an example of array access?

@flipcc
Copy link

flipcc commented Feb 5, 2020

To be honest, I am having difficulties wrapping my head around the implementation of lexers, so I am not qualified to judge if it is a bandaid kind of solution. But your comment made it a good bit clearer what is happing and I am confident that we are looking at the right spot now.
You are right in your assumption that .Properties is not me chaining/calling a function.

@pyrmont pyrmont merged commit 53d1dcd into rouge-ruby:master Feb 11, 2020
@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Feb 11, 2020
@pyrmont pyrmont deleted the bugfix.powershell-array-access branch February 11, 2020 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PowerShell lexer treats lines after variable expansion wrong
2 participants