[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Formatter for Bison Input Files
From: |
Simon Richter |
Subject: |
Re: Formatter for Bison Input Files |
Date: |
Mon, 2 Oct 2023 22:52:16 +0900 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 |
Hi,
On 9/29/23 15:37, Julian Hapke wrote:
having gotten used to using clang-format in C and C++ as well as black
in Python, I would like to try and write a file formatter for a
different language.
There will be a lot of personal preferences involved in this, plus you
will need to contend with "inside {} is a different language which has
its own formatting rules."
My preferred style these days is
rule:
"keyword" IDENTIFIER '{' members '}'
{
multi();
line();
action();
}
| "keyword" IDENTIFIER ';'
{ short_action(); }
because it gives minimal diffs for adding alternatives and for adding
actions after the grammar accepts the example set of inputs, and it also
allows code coverage analysis to give sensible results with tools that
report on a line-by-line basis.
I am fairly sure that there will be a plethora of different styles out
there, all with their own rationale, and there are a few degrees of
freedom inside the Bison syntax that a good formatter will need to
either replicate or make consistent, such as whether rules need to have
a trailing semicolon.
I don't know of any existing tool, but I haven't looked too hard either.
Simon
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Formatter for Bison Input Files,
Simon Richter <=