Answer the question
In order to leave comments, you need to log in
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
Apparently you need
something in the style of
https://clang.llvm.org/docs/ClangFormat.html
But somehow difficult task for the coursework.
I propose to write a wrapper that will call clangformat or something similar. No one will understand anyway :)
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 questionAsk a Question
731 491 924 answers to any question