4

I am using Eclipse CDT (Helios release) to edit the source code of an (old) C application, which also uses ESQL. In this project, by convention, files containing ESQL code have a .sc extension (instead of the default .c)

All ESQL sections e.g. starting with EXEC SQL keywords are flagged as “syntax error” (vertical ruler, overview ruler and amber squiggly line). The actual compilation is performed on a different machine (Unix), which has the ESQL compiler. What can I do to check the syntax of the SQL code on the development machine?

Note: I can hide the notification from Preferences / General / Editors / Text Editors / Annotations / C/C++ Indexer Markers but this may hide possible useful warnings.

apaderno
  • 28,547
  • 16
  • 75
  • 90
Adrian
  • 6,013
  • 10
  • 47
  • 68

2 Answers2

0

If you use the Window->Preferences->C/C++->File Types and define a new file type with C or C++ as *.pc, or *.sc etc. as is appropriate to your extension, then the syntax highlighter will attempt to colour the keywords appropriately and provide hover tips. Of course the EXEC SQL type statements will show up as errors but those are relatively easy to ignore knowing that you're looking for some help for the elements in the file, but not all (i.e. doesn't parse embedded SQL).

Update (for vi(m) lovers): I found that I needed to create a file in ~/.vim/ftdetect/pc.vim containing:

au BufRead,BufNewFile *.pc set filetype=pc

and I also created a link from my /usr/share/vim/vim73/esqlc.vim to pc.vim (though we could have specified *.pc set filetype=esqlc)

and I installed vrapper, then after restarting eclipse, I my EXEC SQL or other keywords were no longer underlined, though they weren't colourized either. That may change in future vrapper updates. (Note: I'm using Eclipse Kepler as it supports vrapper)

Bonus: make sure to set your preferences for "Find and Replace" to CTRL-4 instead of CTRL-F to get page forward in vim working.

John
  • 1
  • 1
0

What you have isn't C code, in spite of what you might think.

Extra "syntax" (e.g, EXEC SQL plus whatever is inside) simply isn't C code, and any tool that processes conventional C code will by necessity reject it as a syntax error.

The "ESQL processor" (sounds like a mainframe given the EXEC SQL phrase) probably preprocesses what you are thinking of a C code to extract the SQL and replace it by function calls; that result is likely fed off to a real C compiler.

I doubt you can do anything useful with this using CDT.

Ira Baxter
  • 93,541
  • 22
  • 172
  • 341