Howto
Download ASN.1 package and unpack it into a folder of your choice.
The ASN.1 grammar are in lexer.g (token scanner) and parser.g (syntax analyser). Example ASN.1 notations are to be found in folder asn1-grammars.
In a first step we are going to generate a ASN.1 parser by calling Antlr on the provided grammar files:
% mkdir gen % antlr -o gen parser.g % antlr -o gen lexer.g
where antlr is a (shell) script packaged with Antlr 2.7.x simplifying the invocation of Antlr. If this script is missing (or you are going to use Ant), then try something like
% java -cp antlr.jar antlr.Tool <>
instead (where antlr.jar is part to the Antlr package).
At this step we have a couple of Java files generated. Those files are the parser. In order to get something runable, we compile those .java files into .class files. This the second step:
% mkdir obj % javac -cp antlr.jar -o ./obj *.java gen/*.java
Finally run the parser on sample input files. You may use option ‘-t’ to dump the generated AST in a lisp like fashion (try -h for usage details). For example.
% java -cp antlr.jar:./obj Main < asn1-grammars/raw/iif.asn
Please expect error message (and an return code larger than zero) if the given ASN.1 notation does not comply with X.680's syntax rules. The semantic aspects of X.680 are not checked.
Good Luck.