Skip to content

grammar freezes #134

Closed
Closed

Description

Opening this file freezes with the latest grammar.

I reverted the VSCode grammar to 6f54386

Activity

  1. changed the title [-]grammar fresses[/-] [+]grammar freezes[/+] on Aug 15, 2018
  2. Serega124 commented on Aug 15, 2018

    @Serega124

    This line has catastrophic backtracking:

    <string>^(?i:(?:\s*|#)+(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))</string>

    Changing the * to ? symbol seems to work.

    via microsoft/vscode#56476

  3. omniomi commented on Aug 15, 2018

    @omniomi
    Contributor

    The difference between the two versions was (?i:\s*(\.) - > ^(?i:(?:\s*|#)+(\.) reason being if you forgot a space after a sentence and had a keyword it would highlight (#119). The * has been there all along but coupled with the + that's what's doing it in. Whether you change it to ^(?i:(?:\s?|#)+(\.) or ^(?i:(?:\s*|#)(\.) the crash stops.

    I will push that ASAP.

  4. added a commit that references this issue on Aug 15, 2018
    3d876cd
  5. msftrncs commented on Aug 16, 2018

    @msftrncs
    Contributor

    I see another minor problem. It appears that PowerShell Get-Help requires these documentation keywords to be the only word on the line (spaces are accepted at the end of the line, but not even '#'). (not sure if its true for all of them, PARAMETER which does accept additional text is in a different pattern) Also, I am not getting any scoping of these documentation keywords if they are on a single line comment, but PowerShell Get-Help seems to accept that. It even seems to accept <# #> # .SYNOPSIS but any other non space characters are not accepted.

    Seems that it might be that the same pattern (repository?) is used for both comment types, but the match here requires being at the beginning of the line, and I am not sure if that reference is valid inside the 'include' of another pattern? I tried it, modifying my tmLanguage.json file on VS Code, copying the commentEmbeddedDocs pattern to slCommentEmbeddedDocs and removed the ^ from the match, and changed the include reference on commentLine and that seems to get the single line comment's to work (scope and color for the documentation keyword). I'm not sure how the rest of the rules can be adhered to.

    trial and error seems to indicate get-help only supports spaces at the start of multi-line comments, and only accepts consecutive '#'s immediately after the start of a single line comment. I finally determined that \G would fix that.

    		"commentEmbeddedDocs": {
    			"patterns": [
    				{
    					"captures": {
    						"1": {
    							"name": "constant.string.documentation.powershell"
    						},
    						"2": {
    							"name": "keyword.operator.documentation.powershell"
    						}
    					},
    					"match": "^(?i:\\s*(\\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))",
    					"name": "comment.documentation.embedded.powershell"
    				},
    				{
    					"captures": {
    						"1": {
    							"name": "constant.string.documentation.powershell"
    						},
    						"2": {
    							"name": "keyword.operator.documentation.powershell"
    						},
    						"3": {
    							"name": "keyword.operator.documentation.powershell"
    						}
    					},
    					"match": "^(?i:\\s*(\\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\\s+([a-z0-9-_]+))",
    					"name": "comment.documentation.embedded.powershell"
    				}
    			]
    		},
    		"slCommentEmbeddedDocs": {
    			"patterns": [
    				{
    					"captures": {
    						"1": {
    							"name": "constant.string.documentation.powershell"
    						},
    						"2": {
    							"name": "keyword.operator.documentation.powershell"
    						}
    					},
    					"match": "\\G(?i:#*\\s*(\\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))",
    					"name": "comment.documentation.embedded.powershell"
    				},
    				{
    					"captures": {
    						"1": {
    							"name": "constant.string.documentation.powershell"
    						},
    						"2": {
    							"name": "keyword.operator.documentation.powershell"
    						},
    						"3": {
    							"name": "keyword.operator.documentation.powershell"
    						}
    					},
    					"match": "\\G(?i:#*\\s*(\\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\\s+([a-z0-9-_]+))",
    					"name": "comment.documentation.embedded.powershell"
    				}
    			]
    		}

    (JSON from VS Code)

  6. msftrncs commented on Aug 16, 2018

    @msftrncs
    Contributor

    Quick correction: The ^ should be changed to (?:^|\\G), as get-help allows the keyword on the same line as the start of the multiline comment, but with nothing other than spaces between.

  7. msftrncs commented on Aug 16, 2018

    @msftrncs
    Contributor

    and a final correction, I completely missed the first point I brought up, get-help doesn't allow anything trailing on the keyword lines that do not pass an argument for the help keyword.

    Add (?:\\s*$) to the end of the matches with only two captures.

    Edited to add '*' after '\s'

  8. Jaykul commented on Aug 16, 2018

    @Jaykul

    Carl Morris (@msftrncs) probably should open a separate issue to track that.

  9. msftrncs commented on Aug 16, 2018

    @msftrncs
    Contributor

    I was able to come up with a better solution that doesn't require an additional repository item, I'll include this all in a new issue.

  10. added a commit that references this issue on Aug 28, 2018
    12b7d72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions