Skip to content

Conversation

@tgauth
Copy link
Collaborator

@tgauth tgauth commented Nov 20, 2025

PR Summary

  • update sshd config grammar so quotedString node is not hidden

PR Context

  • need to differentiate between strings and quoted strings when parsing arguments that are space-separated (i.e. allowgroups admins devs "openssh users")

@tgauth tgauth requested a review from Copilot November 20, 2025 22:45
Copilot finished reviewing on behalf of tgauth November 20, 2025 22:47
@tgauth tgauth requested a review from SteveL-MSFT November 20, 2025 22:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR makes the quotedString grammar node visible in the parse tree by removing the underscore prefix from _quotedString to quotedString. This change enables proper differentiation between regular strings and quoted strings when parsing space-separated arguments in SSH server configuration files (e.g., allowgroups admins devs "openssh users").

  • Updated grammar rule from hidden _quotedString to visible quotedString
  • Updated all test expectations to include the quotedString node in parse trees

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
grammars/tree-sitter-ssh-server-config/grammar.js Changed _quotedString to quotedString in both the rule definition and the arguments choice, making the node visible in the parse tree
grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt Updated 6 test cases to expect quotedString nodes wrapping string nodes in the parse tree output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


_commaSeparatedString: $ => seq($.string, repeat(seq(',', $.string))),
_quotedString: $ => seq('\"', $.string, '\"'),
quotedString: $ => seq('\"', $.string, '\"'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the parser, you don't care if it's quoted or not, but simply the result is the contents between the quotes (if provided), right? Can't you define a string as a choice between quoted and not quoted where the quoted is just the contents between the quotes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full scenario the Rust parser is running into:

The existing parser has a test for:
allowgroups group1 "group with spaces"

However, the existing parser would parse this scenario:
allowgroups group1 group2

as a single string, "group1 group2" instead of "group1" and "group2"

To support both, I plan to update the Rust parser to be able to split "string" nodes by spaces but not "quoted string nodes"

It may be easier to consolidate the grammar and parser changes because this has broken the parser anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option would probably be to update the grammar to not declare space in extras but that may have broader impact

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think space in extras is fine to allow arbitrary whitespace, but the Rust parsing code should just handle the tokens returned by the grammar and not have to worry about the enclosing quotes and just the contents which can contain whitespace. I think this should be possible by defining as (pseudo-grammar):

[keyword] [parameter]+

where [parameter] is choice([string], [number], [yes/no], etc...) and [string] is either a bareString or quotedString, but the parser just gets it as a string.

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.

2 participants