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

Add missing keywords for SAS. #922

Merged
merged 2 commits into from
Mar 31, 2016
Merged

Add missing keywords for SAS. #922

merged 2 commits into from
Mar 31, 2016

Conversation

chucknelson
Copy link
Contributor

Two changes:
(1) PROC keyword now also includes its associated name (e.g., PROC TABULATE, PROC SQL).
(2) QUIT now included, as it is used to close/complete various procedures.

Two changes:
(1) PROC keyword now also includes its associated name (e.g., PROC TABULATE, PROC SQL).
(2) QUIT now included, as it is used to close/complete various procedures.
@zeitgeist87
Copy link
Collaborator

Hi @chucknelson

Thanks for your contribution.

First of all I have never used SAS, so please correct me if I am wrong on the language specific details. As I understand it, the proc keyword calls some kind of library function. If that is true, wouldn't it be better to highlight the function name as a function instead of as a keyword:

    'function': {
        pattern: /(\bproc\s+)\w+\b/i,
        lookbehind: true
    },
    'keyword': /\b(?:data|else|format|if|input|proc|quit|run|then)\b/i,

@chucknelson
Copy link
Contributor Author

Hi @zeitgeist87,

PROC is actually a "special" boundary/step in SAS, similar to the DATA step. For more info, SAS documentation is a good reference for how they refer to some of these concepts (the PROC step in this case).

Functions are also a concept in SAS, but more of what you expect, passing parameters within parentheses (e.g., x = SUM(a, b);).

This was just a little "warm up" contribution, but the eventual goal I want to hit is to get SAS support much more complete in Prism, eventually trying to mimic what users are familiar with in the Base SAS editor when it comes to syntax highlighting, as seen below:

image

Any thoughts on how we can work towards that goal? Thanks!

@zeitgeist87
Copy link
Collaborator

PROC is actually a "special" boundary/step in SAS, similar to the DATA step. For more info, SAS documentation is a good reference for how they refer to some of these concepts (the PROC step in this case).

I see. In that case ignore my previous comments.

This was just a little "warm up" contribution, but the eventual goal I want to hit is to get SAS support much more complete in Prism, eventually trying to mimic what users are familiar with in the Base SAS editor when it comes to syntax highlighting, as seen below:

That would be great. I am happy to help if you have any questions concerning the implementation. Unfortunately I know next to nothing about SAS.

The regex proc\s\S+ only allows a single space between proc and the procedure name. Is this intentional? \S+ matches anything that is not a space, which is probably too much. For example your regex matches proc te;st. I would suggest something like proc\s+\w+

@chucknelson
Copy link
Contributor Author

The single space was intentional due to how PROC is always followed by a single space and then a single word name, but I definitely agree with your change to a word match versus the way-too-open \S+ I had in there.

I'm going to push a new commit with the regex change for PROC. I think for this small pull request we should keep things in keywords for now, and I'll play around in my own fork on how I can get the SAS language implementation more complete in general (which may involve custom token names, not sure yet).

I also have an issue open on how to do language-specific styling for included languages like SAS (#923), in an effort to get to that Base SAS editor styling I mentioned. If you have any input on that I'd really appreciate it! Thanks!

@zeitgeist87 zeitgeist87 merged commit 648aec0 into PrismJS:gh-pages Mar 31, 2016
@zeitgeist87
Copy link
Collaborator

I also have an issue open on how to do language-specific styling for included languages like SAS (#923), in an effort to get to that Base SAS editor styling I mentioned. If you have any input on that I'd really appreciate it! Thanks!

There is currently no support for themes that are only used for specific languages. To get the colors you want, you have to create your own theme. The language definition can only define the tokens. The themes set the colors.

However the alias property is very useful to get the colors you want out of a general purpose theme.

'semantically-correct-token-name': {
    pattern: /something/,
    // use the same color as 'number'
    alias: 'number'
}

If your theme looks good with SAS it'll probably look good with other languages too. Then you can submit it to https://github.com/PrismJS/prism-themes

@chucknelson
Copy link
Contributor Author

Great, thanks so much! I'll do what I can to help build out some of the SAS support :)

@chucknelson chucknelson deleted the add-missing-keywords-for-sas branch March 31, 2016 18:07
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

Successfully merging this pull request may close these issues.

None yet

2 participants