Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<CODE SAS> highlighting inside PROC SQL #114

Open
nickvence opened this issue Oct 24, 2018 · 5 comments
Open

<CODE SAS> highlighting inside PROC SQL #114

nickvence opened this issue Oct 24, 2018 · 5 comments

Comments

@nickvence
Copy link

nickvence commented Oct 24, 2018

SAS has a PROC SQL statement which contains different (SQL) syntax. The syntax highlighting should reflect this.

sascode

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;
@Klap-in
Copy link

Klap-in commented Oct 24, 2018

Please, post the example also as text (the picture is not selectable).

@Klap-in
Copy link

Klap-in commented Oct 25, 2018

It is a multiline comment according to definition file:

'COMMENT_MULTI' => array('/*' => '*/', '*' => ';'),

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?

@nickvence
Copy link
Author

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.

@nickvence
Copy link
Author

nickvence commented Oct 25, 2018

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.

@BenBE
Copy link
Contributor

BenBE commented Mar 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants