Pro*C syntax
Submitted by Monday, 24 November, 2008 - 20:21
on
I'm trying to make a ruleset for Pro*C syntax. Pro*C is C run through Oracle's precompiler which allows you to embed SQL directly into C.
Here are the simple rules I have that come close to working.
EXEC SQL CREATE
END-EXEC;
EXEC SQL EXECUTE BEGIN
END-EXEC;
EXEC SQL EXECUTE DECLARE
END-EXEC;
EXEC SQL
;
The problem with these rules is that "EXEC", "SQL", "CREATE", "EXECUTE", "BEGIN", and "DECLARE" can all appear on separate lines.
I tried creating separate rule sets, but I don't see a way to include a default case that changes the ending delimiter for the block.
I also messed with regular-expressions via SPAN_REGEXP, but these only work on a single line at a time (which makes sense for speed) and can't just match the first character.
Any ideas?
Here's snippit that I've been using for testing.
EXEC
SQL CREATE
select * from should_be_highlighted;
END-EXEC;
select * from should_NOT_be_highlighted;
EXEC SQL
EXECUTE select * from should_be_highlighted;
select * from should_NOT_be_highlighted;
EXEC SQL EXECUTE select * from should_be_highlighted;
select * from should_NOT_be_highlighted;
EXEC SQL select * from should_be_highlighted;
select * from should_NOT_be_highlighted;
EXEC SQL BEGIN DECLARE SECTION;
select * from should_NOT_be_highlighted;
EXEC SQL END DECLARE SECTION;
select * from should_NOT_be_highlighted;
EXEC
SQL
EXECUTE
BEGIN
select * from should_be_highlighted;
select * from should_be_highlighted;
END-EXEC;
select * from should_NOT_be_highlighted;
EXEC
SQL
select * from should_be_highlighted
;
select * from should_NOT_be_highlighted;
EXEC SQL EXECUTE BEGIN select * from should_be_highlighted;select * from should_be_highlighted;select * from should_be_highlighted;END-EXEC;
select * from should_NOT_be_highlighted;
EXEC SQL EXECUTE
BEGIN select * from should_be_highlighted;select * from should_be_highlighted;select * from should_be_highlighted;END-EXEC;
select * from should_NOT_be_highlighted;