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

Evaluate gnatpp #20

Open
jklmnn opened this issue May 7, 2020 · 7 comments
Open

Evaluate gnatpp #20

jklmnn opened this issue May 7, 2020 · 7 comments

Comments

@jklmnn
Copy link
Member

jklmnn commented May 7, 2020

A tool for automated formatting is desirable. Gnatpp seems to be the only tool available for Ada however it doesn't exactly create our desired code style. We should check if the gnatpp style is viable and how we could adapt it for our needs.

@isaahzorgh
Copy link

Using Gnatpp, it still will not match the ada-style guide.
There are simply too few options to specify how the code should be formatted and the style guide has too many exceptions for such a simple tool.

Using the tool results in the following code style where there is no option to specify how the lines should be aligned:

      Pre => (for all P in GPIO.Pin => GPIO.Valid (P)) and then (for all P of Pins => GPIO.Configured (P))
      and then (for all P of Pins => GPIO.Pin_Mode (P) = GPIO.Port_Out),
      Post => (for all P in GPIO.Pin => GPIO.Valid (P))
      and then (for all P of Pins => GPIO.Pin_Mode (P) = GPIO.Port_Out)
      and then (for all P in GPIO.Pin => GPIO.Pin_Modes (P) = GPIO.Pin_Modes'Old (P))
      and then (for all P in GPIO.Pin => GPIO.Pins_Configured (P) = GPIO.Pins_Configured'Old (P)),
      Global => (In_Out => GPIO.GPIO_State, Proof_In => GPIO.Shadow_Configuration_State);

And as discussed in Issue #19 this style is not desirable as the distinction between the different parts of the contract is not clear enough.

@senier
Copy link
Member

senier commented May 13, 2020

@isaahzorgh Which version of gnatpp did you test with?

@jklmnn
Copy link
Member Author

jklmnn commented May 14, 2020

We used GNATPP Community 2019 (20190517).

@senier
Copy link
Member

senier commented May 14, 2020

Can you please try with Pro 21. IMHO the contract layout would qualify for a bug report. Are there other things where the tool deviates significantly from our desired style?

@isaahzorgh
Copy link

isaahzorgh commented May 14, 2020

For clarification, we used the following commands for Gnatpp:

--no-seperate-loop
--no-seperate-then
--preserve-blank-lines
--vertical-enum-types
--vertical-array-types
--pragma-mixed-case
--type-case-as-declared
--number-case-as-declared
--enum-case-as-declared
--name-case-as-declared
--attribute-mixed-case
--keyword-lower-case
--alignment
--align-modes
--indentation=3
--indent-continuation=3  (altough we first tested with =0)
--max-line-length
--use-on-new-line
--split-line-before-op
--split-line-before
--par-threshold=1
--vertical-case-alternatives
--vertical-named-aggregates

@jklmnn
Copy link
Member Author

jklmnn commented May 14, 2020

Can you please try with Pro 21. IMHO the contract layout would qualify for a bug report. Are there other things where the tool deviates significantly from our desired style?

After a separate discussion, we discovered that Pro 21 has the same problems.

@jklmnn
Copy link
Member Author

jklmnn commented May 21, 2020

Maybe we might take a look into https://github.com/reznikmm/ada-pretty.git. It seems to be for generating code only now but maybe one could create a front end that reads Ada code and uses this project as a back end.

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

No branches or pull requests

3 participants