geshi-1.0
geshi-1.0 copied to clipboard
<CODE SAS> highlighting inside PROC SQL
SAS has a PROC SQL statement which contains different (SQL) syntax. The syntax highlighting should reflect this.
Problem code: the asterisk in the select statement is treated as a SAS comment.
proc sql;
select count(*) AS Total, d.OwnRent, d.AssistedLiving, d.NursingHome, d.LiveWFam
from Dwelling2 as d
group by d.OwnRent, d.AssistedLiving, d.NursingHome, d.LiveWFam
order by Total DESC;
quit;
Please, post the example also as text (the picture is not selectable).
It is a multiline comment according to definition file: https://github.com/GeSHi/geshi-1.0/blob/5861c58981244ab6ee0dd337f096ff14bf15b1eb/src/geshi/sas.php#L47
According to most manuals the comment should just start with *
... So I guess internally there is some check to prevent these undesired comments...but this check is not clear from manual.
https://libguides.library.kent.edu/SAS/syntax
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000289375.htm
Some examples with syntax highlighter of Github, no idea if that one is right at all?:
proc sql;
select count(*) AS Total, d.OwnRent, d.AssistedLiving, d.NursingHome, d.LiveWFam
from Dwelling2 as d
group by d.OwnRent, d.AssistedLiving, d.NursingHome, d.LiveWFam
order by Total DESC;
quit;
proc sql; *df
dfdf;
proc sql; *text;
proc sql; (*)text;
proc sql; *)text;
proc sql; (*text;
proc sql; k*ktext;
proc sql;*ktext;
proc sql;k* text;
proc sql; k* text;
proc sql; *text 2spaces before
So question is, what should be the exact logic for these comments?
The IDE that comes with SAS allows /* */ style commenting inside PROC SQL, but it doesn't allow * ; style commenting inside PROC SQL. This should simplify the logic.
Thanks! You have correctly articulated another highlighting inconsistency. The Rule: an asterisk begins a comment if there is only whitespace between it and the previous semicolon.
I see some issues with getting this to work in GeSHi 1.0 as this requires some context we don't usually have and that also can't easily be done with constant PCRE look-behind. Thus most likely having GeSHi work out the two separate language contexts on its own might be somewhat complicated and probably not possible with the GeSHi 1.0 parser. GeSHi 1.1 should be able to pull this off though. Solutions in GeSHi 1.0 will likely be a compromise on what is reliably detectable.