writing a few lines of comments that work in most languages
i want to write some reasonably arbitrary text as comments to be prepended and/or appended to source code for most languages or all major languages used in BSD or Linux the code that will write this commented text will not know which language it is, or get to even see the code that the comments will be attached to for to guess the language. the comments will not be inserted in the middle of the code so multi-line code (such as multi line triple quotes in python) will not be affected.
the language i will be coding this in needs to not matter. i will prototype it in one language and finalize it in another. others may translate it to the language they use, maybe FOSS, maybe not. |
Quote:
Could you be a little more vague please? [/humor-sarcasm] Asking for a near universal generated markup syntax, originating from an application defined by language independent source is a bit of a stretch for my tired old brain cell. Even a UML transform direct from model to source will require knowledge of the target language. You seem to be asking for a single comment syntax which will be recognized by any arbitrary language compiler or interpreter... and I cannot easily parse what you mean by a generating application which is itself language independent (i.e. a universal executable model). A clear description of your ultimate use case would probably help others, certainly myself to understand what you are asking. |
As is the case with many of your questions, the answer is that there is no such thing.
|
would be nice to show an example, but maybe not
|
Maybe you could use emojis, they are language-independent.:twocents:
|
Quote:
|
Quote:
i remember my college days when a friend wrote a mainframe program that took in source code, detected the language, and invoked the compiler for that language feeding it the whole original file. i then created a file that could be fed to either the Fortran compiler or the PL/1 compiler with each producing different binaries that did the same thing (copied input to output). i ran it both ways and showed him the results (printed job output back in those days) and asked him which language his program would choose. he tried his program on my source code. his program hung in a loop. of course that was a limited scope of just two specific languages. i later tried to do the same thing with COBOL but was unsuccessful. |
still not understand what are you looking for. Usually we have flowcharts, which means we have some kind of input data and would like to process it and finally produce some kind of output. The flowchart will explain the process itself, step by step, but it is not executable. It should be translated to something which can really do the job. That's why we have programming languages. But you can almost never translate a real source code from one language to another, there is no such tool. And because of the complexity (and incompatibility) of the existing languages it will never exist.
(even moving from python2 to python3 or perl5 to perl6 are not that trivial and works only in one direction) So what are you really looking for? a general pseudo-language, which can be used to generate real source code on different languages? No, that does not exist and never will. More than 25 years ago there was a c++ -> c cross compiler (translator?) (because that time we did not have real c++ environment), but the result was terrible. |
Quote:
On-Topic: one of my (2) ingenuous bosses developed a generic code generator, based on XML and some pipeline-architecture, similar to a big XML-munging Java-framework the name of which I cannot remember right now (began with a 'C' *) ). The first version and the only one I was involved with, spit out C++ code for GUI-elements that were drawn in a vector-graphics editor with the capacity to parameterize “actions”. You draw, you push button, you include, compile and link => Your military submarine-simulator. Enjoy. When the customers had become too fearsome, it all came to a halt, but in the meantime, the thing has evolved into a payed online-application. In a version I saw, it could produce Java as well. This is not something very revolutionary, the guy had simply been too early with the idea (to “never having to program anything at all”). Code-comments were – of course – coming with the XML-code, as well. Edit: *) Cocoon ! The similarities were though accidental. |
So your boss built an in-house CASE application? Impressive.
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
I recommend that you implement some kind of template-driven system. First detect the language, then invoke the appropriate template for that language.
|
All times are GMT -5. The time now is 06:28 AM. |