Syntax highlighting for a SAS code

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Audimar Bangi
Avatar
Hello,

I'm evaluating your product to see if it can be used to write a commercial SAS editor. Is it possible to highlight the following variants of a SAS code (keywords: data, run):

(1) Variation 1 (collapsible, priority 1, with "run;" statement as end of block)

data mydata;
...line of code 1;
...line of code 2;
run;

proc report;
...line of code 1;
...line of code 2;
run;


(2) Variation 2 (collapsible, priority 2, no "run;" statement; last statement ends the block when the start of a new block is encountered)

data mydata;
...line of code 1;
...line of code 2;

proc report;
...line of code 1;
...line of code 2;
run;

Thanks, Audi

Comments (4)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Audi,

Sure, SyntaxEditor can be used to highlight any language easily. The fastest way to get started is with a dynamic language where you define regular expression patterns and lists of words to highlight various colors.

Outlining (collapsing node capabilities) can be easy or a little trickier depending on the language. In your variation 1, that is pretty easy to set up since there is a well defined start and end of the block.

In variation 2, that is tricker and would take a bit more advanced code to do. Since in that variation, you must be doing additional scanning to figure out whether a new block is starting and end the previous one if it is. This can be done by using our grammar designer to construct a semantic parser that builds AST nodes of your document. If you make the appropriate AST nodes (like data or proc nodes) to be collapsible nodes, then those can get passed back to the outlining engine and this feature can be accomplished. I believe our Simple language shows this sort of advanced outlining.


Actipro Software Support

Posted 16 years ago by Audimar Bangi
Avatar
Hi,

Thanks! I would appreciate it very much if you could show me a sample code for implementing variation 2.

Regards, Audi
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hello, take a look at the "Simple" language implementation in our sample project. That is about as simple of a language implementation as you can do for a language that has all the advanced features like semantic parsing, AST, automated IntelliPrompt, outlining based on ASTs, etc.

ActiproSoftware.Simple.Grammar.xml contains the definition for the semantic parser, which when run through our Grammar Designer creates SimpleSemanticParser.cs. Then in the SimpleSyntaxLanguage.PerformAutomaticOutlining override, we use the CompilationUnit AST tree to generate the outlining nodes.

Note that in the grammar, the FunctionDeclaration AST node is declared to implement ICollapsibleNode meaning it will become an outlining node per the code called by SimpleSyntaxLanguage.PerformAutomaticOutlining.


Actipro Software Support

Posted 16 years ago by Audimar Bangi
Avatar
Hello,

Can't implement variation 2.

Thanks, Audi
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.