tree-sitter / tree-sitter

An incremental parsing system for programming tools

Home Page:https://tree-sitter.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a particular reason why inlining happens _after_ checking?

yanok opened this issue · comments

Problem

It's more a question than a FR.

Let's say I'm translating the EBNF grammar and what to keep the structure as close as possible. So I end up with a non-starter rule that can match empty input, so tree-sitter complains about it. That's actually super easily solvable, KUDOs for using a programming language to write a grammar, I can just turn these rules into functions.

But there is also this inline feature, that looks appealing, so I though I should be able to just inline these rules. Unfortunately that doesn't work: the check for rules matching an empty input is done before inlining, so tree-sitter still complains.

So, my question is: is there a particular reason for this ordering? Could we do inlining first, and then probably some bad rules will go away already?

Expected behavior

No response