logo back up home forward   further reading more topics »

XES - Programmers Guide - Parser Generator

If you need to change or correct the syntax then it may be best to go back to the parser generator, to do this you need to:

Get javacc from Sun site

Goto https://javacc.dev.java.net/ to the following page:

scroll down to 'getting the software' and click on 'download':

After clicking on download choose which version:

When the file has been downloaded choose and run a suitable program to extract:

Extract all the files to a suitable directory:

Get java2xes.jjt file

You can get the parser generator for XES from the sourceforge web site http://sourceforge.net/projects/xes/ click on download and choose the source files xes_java_src_ver08.zip and also the paser generator files: parserGenerator_ver08.zip. Download both of these to a suitable directory. Then use a suitable program to extract them to the same directory.

run jjtree

I made a batch file to run jjtree which contains the following:

C:\Borland\JBuilder2005\jdk1.4\jre\bin\java -classpath "javacc-3.2\bin\lib\javacc.jar" jjtree java2xes.jjt

You will need to modify this depending on where your files are located.

Assuming that you have downloaded the node source file to the same directory as suggested then javacc will detect them and realise that it does not need to overwright them.

run javacc

I made a batch file to run javacc which contains the following:

C:\Borland\JBuilder2005\jdk1.4\jre\bin\java -classpath "javacc-3.2\bin\lib\javacc.jar" javacc java2xes.jj

You will need to modify this depending on where your files are located.

This uses the java2xes.jj file which is an output of the jjtree stage above.

Compiling code generated

What I do is to put java2xes.jjt in a directory on its own, then run jjtree which produces java2xes.jj and a lot of .java files, then run javacc on java2xes.jj which produces some more .java files.

It seems to me that the java files generated are in different types:

I think that the files that contain ‘JavaParser’ in their name are specific to this grammer (there are a different set for ‘csParser’) these files are: JavaParser.java, JavaParserConstants.java, JavaParserTokenManager.java, JavaParserTreeConstants.java, JavaParserVisitor.java, JJTJavaParserState.java. These files all depend on each other so a version from one grammar should not be used with one from a different grammar.

I would then copy all these files to your java environment to replace the existing versions and compile.

The files representing tree nodes are only skeleton files. I have modified these to give the functionality required so we don’t want to use the files just generated (if existing versions of these files are in the directory then they should not be overwritten). If you compile with these skeleton files then there will be compiler errors because they wont match the code fragments inserted into the grammar.

AnnotationTypeDeclaration.java, MarkerAnnotation.java, MemberValue.java, MemberValueArrayInitializer.java, MemberValuePair.java, MemberValuePairs.java, Node.java, nodeAnnotation.java, nodeAssert.java, nodeAssign.java, nodeBinaryOp.java, nodeBlock.java, nodeBreak.java, nodeCall.java, nodeCase.java, nodeClassDef.java, nodeConstant.java, nodeEnumDec.java, nodeIf.java, nodeImport.java, nodeLabel.java, nodeLoop.java, nodeMethodDec.java, nodeNameList.java, nodePackageDec.java, nodeParameter.java, nodeParameterList.java, nodeReturn.java, nodeSwitch.java, nodeTry.java, nodeTypeOp.java, nodeUnaryOp.java, nodeVariable.java, NormalAnnotation.java

There also seem to be some files that have fixed functionality and don’t depend on the grammar (although, some like ‘Token.java’ have been modified to fix bugs).

JavaCharStream.java, ParseException.java, SimpleNode.java, SingleMemberAnnotation.java, SynchronizedStatement.java, Token.java, TokenMgrError.java


metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Processing XML with Java: A Guide to SAX, DOM, JDOM, JAXP, and TrAX

Other Java books

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

cover JBuilder - There is also a free version of Jbuilder at borland website . However its licence conditions are quite restrictive so you may prefer another java IDE.

Can this page be improved?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

for xml encoding: http://sourceforge.net/projects/xes/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.