User forums > General (but related to Code::Blocks)
How to add another programming language to C::B? Preparsers?
MortenMacFly:
--- Quote from: gafling on February 19, 2017, 02:06:13 pm ---One language that I would like to be able to integrate into C::B is Cobol.
--- End quote ---
A lexer for C::B seems feasible (Cobol is supported by scintilla). However, the build system is not really suited to integrate the compiler easily. It could work with custom pre-compiler steps or customising compiler commands.
However, for Cobol I would recommend an own plugin from scratch, similar how its done for Fortran. You will certainly work mainly on the Cobol files and not on the underlying C-Code, won't you? So you'll need more support than just the lexer. Its really similar to Fortran that also translates to C (well hidden) using the GNU compiler tool chain.
So if you want to start such effort, have a look at the Fortran plugin. For the custom lexer you can do it probably yourself, if you read this:
http://wiki.codeblocks.org/index.php/Creating_a_custom_lexer_for_Code::Blocks_editor
cb_mensch:
As GnuCOBOL knows best how to call the underlying C compiler (depending on the C compiler it was built with/configured for and depending on the given command line options to the GnuCOBOL compiler `cobc`) - I guess this is what is done for Fortran, too - I'd suggest to not use it as a pre-compiler step but as a "real" compiler.
A different thing is that COBOL is often used via pre-parsers (for example `EXEC SQL` and lot of COBOL-shop-specific-self-written-pre-parsers), therefore it would be nice to end with an option for the chain Source -> Pre-Parser-Step X (for example a shop specifc one) -> maybe Pre-Parser-Step Y (for example the SQL preparser `dbpre`, Oracle's `procob` or whatever) -> plain COBOL source -> `cobc` (+ internal: `gcc`, `clang` or `cl.exe`).
And yes, I think a full-integrated approach - which seems to need a plugin, given the comments so far - would be best.
cb_mensch:
Just to note: the Scintilla Lexer is still nearly unchanged and can be found at https://sourceforge.net/p/scintilla/code/ci/default/tree/lexers/LexCOBOL.cxx (obviously patches for this lexer should go there, first).
Question: if the file is updated can the main change `Sci_PositionU` / `Sci_Position` instead of `(unsigned) int` be used for C::B or not?
oBFusCATed:
We'll update scintilla to 3.7.x soon. So if there is cobol lexer in it will have it.
Scintilla 4.x.x requires c++14/17, so we won't be using it for quite a while...
cb_mensch:
Yes, the COBOL lexer is part of Scintilla 3.7.
The thing that is still unclear for me is how to actually *use* the lexer at all (it would be nice to at least allow file types to be assigned using it) and it is unclear where the keyword list for the lexer comes from (I can provide a word list for multiple COBOL dialects [and actually it would be nice to be able to choose the keyword list somewhere).
A different question would be if / how it is possible to use an external (non-c) compiler for these files...
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version