0
votes

I am trying to use ANTLR for parsing SAS jobs and creating parser based on that.

I am using SAS grammar from https://github.com/xueqilsj/sas-grammar and using ANTLR for parsing and lexical analyzer. I am also using the link provided here: https://shijinglu.wordpress.com/2015/01/22/write-a-primitive-sas-grammar-in-antlr4/ .

Just to clarify, every SAS gramamr is of the format:

grammar AbortStmt; 

import CommonLexerRules; 

abort_main
 : (abort_stmt)* EOF 
 ; 

abort_stmt
 : ABORT (ABEND | CANCEL (file_spec)? | RETURN )? INT? NOLIST? ';'
 ; 

file_spec
 : STRINGLITERAL 
 ; 

and I am having problem with the import statement. After I have created the autogenerated class using ANTLR , I am getting the following error:

  1. Can't load AbortStmtBaseListener.class as lexer or parser.
  2. Can’t import the Rules.

I am limited by the SAS imports that are defined in the grammar file(as every grammar file has a defined import). Any other ways to parse the grammar files and create decision trees?

1
Just to clarify,every SAS gramamr is of the format: grammar AbortStmt; import CommonLexerRules; abort_main : (abort_stmt)* EOF ; abort_stmt : ABORT (ABEND | CANCEL (file_spec)? | RETURN )? INT? NOLIST? ';'; file_spec: STRINGLITERAL ; and I am having problem with the import statement.Pranab

1 Answers

0
votes

Once you run ANTLR on the grammar, the result is a group of .java files. Did you then run javac to compile them into .class files? That might account for your problem. I've forgotten to do that before. After that you can run TestRig to see your tokens or the graphical representation of your parse.