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

feat(zig): multiline #253

Merged
merged 1 commit into from
Apr 28, 2023
Merged

feat(zig): multiline #253

merged 1 commit into from
Apr 28, 2023

Conversation

uchars
Copy link
Contributor

@uchars uchars commented Apr 28, 2023

I could not find any example for LoopType- and IfTypeExpr, and i do not understand enough about treesitter to write them using the tree-sitter-zig code.
The TypeExpr would essentially just be

(LoopTypeExpr
  (_ (_TypeExpr (_) @context.end))
) @context

but i am not really sure if doing something like

(LoopTypeExpr
  (_ (_ (_) @context.end))
) @context

is a good idea.

Zig definitions

LoopStatement (https://github.com/maxxnino/tree-sitter-zig/blob/0d08703e4c3f426ec61695d7617415fff97029bd/grammar.js#L266):

LoopStatement: ($) =>
            seq(
                optional(keyword("inline", $)),
                choice($.ForStatement, $.WhileStatement)
            ),

ForStatement: ($) =>
	choice(
		seq($.ForPrefix, $.BlockExpr, optional($._ElseStatementTail)),
		seq($.ForPrefix, $.AssignExpr, choice(SEMICOLON, $._ElseStatementTail))
	),

WhileStatement: ($) =>
	choice(
		seq($.WhilePrefix, $.BlockExpr, optional($._ElseStatementTail)),
		seq(
			$.WhilePrefix,
			$.AssignExpr,
			choice(SEMICOLON, $._ElseStatementTail)
		)
	),

LoopTypeExpr (https://github.com/maxxnino/tree-sitter-zig/blob/0d08703e4c3f426ec61695d7617415fff97029bd/grammar.js#L474):

LoopTypeExpr: ($) =>
            seq(
                optional(keyword("inline", $)),
                choice($.ForTypeExpr, $.WhileTypeExpr)
            ),

ForTypeExpr: ($) =>
	prec.right(seq($.ForPrefix, $._TypeExpr, optional($._ElseTypeExprTail))),

WhileTypeExpr: ($) =>
	prec.right(seq($.WhilePrefix, $._TypeExpr, optional($._ElseTypeExprTail))),

@lewis6991 lewis6991 merged commit 6f00b0f into nvim-treesitter:master Apr 28, 2023
1 check passed
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.

None yet

2 participants