A
A
Andrey Vasots2018-06-18 20:10:38
C++ / C#
Andrey Vasots, 2018-06-18 20:10:38

Code formatting correction applications?

Sobsna was given the topic of the course "Development of an application for correcting code formatting in the C ++ / C # programming language" and allowed them to "float freely", without explanation, etc.
Please explain the essence of this application.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Taratin, 2018-06-18
@Taraflex

Apparently you need something in the style of
https://clang.llvm.org/docs/ClangFormat.html But somehow difficult task for the coursework.

V
Vitaly, 2018-06-18
@vt4a2h

I propose to write a wrapper that will call clangformat or something similar. No one will understand anyway :)

M
Mercury13, 2018-06-19
@Mercury13

First. We need a highly simplified parsing that divides the code into preprocessor directives, tokens, operators, and comments that understands the nesting of operator brackets.
Second. We throw all these tokens into the output stream, adding insignificant characters at our discretion.
Third. Comments will also have to be reformatted, and with this a separate hemorrhoids.
For C, there is also #define. The ideal is to expand each #define, adding the special characters “this is where #define starts”, “this is where #define ends”, format the code, move the left special character as far to the right as possible over insignificant characters (and the right one as far to the left as possible), and then omit everything between the special characters , leaving only the #define as it was.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question