XES - Programmers Guide - parsing

The parser for this program was generated by javacc and jjtree as follows:

I have loaded Java1.5.zip from here.

This parser does not generate XES directly but generates a tree structure which this program then converts into XES.

javacc jjtree

I have draw out part of the tree structure this javacc parsor will create here.

The convertion between these tree structures is described below:

Variables, declaration and assign.

Variables may be defined, initialised and used in the same statement or in seperate statements. Any variables may also be used in arrays.

All of these things are based on variable node, even assignment will allways have a varible on the left hand side.

When a variable is used we need a quick way to link it back to its definition, how do we define such a link? we need to do this both for local variables, class varibles and varibles in other classes, how do we implement late binding of variables?

Should all node names be expanded out to their full path name?

 

 

Java example java1.5.zip tree structure XES tree structure XES
int var1;
     
<variable name="var1" type="int"/>
var1 = 1;
<variable name="var1">
  <assign operator="=">
    <constant intConst="1"/>
  </assign>
</variable>
int var2 =2;
<variable name="var1" type="int">
  <assign operator="=">
    <constant intConst="2"/>
  </assign>
</variable>
int[] array1;
<variable name="array1" type="int" array="true"/>
array1 = new int[1];
<variable name="array1">
  <assign operator="=">
    <array>
      <constant intConst="1"/>
    </array>
  </assign>
</variable>
array1[0]=3;
<variable name="array1">
  <array>
    <constant intConst="0"/>
  </array>
  <assign operator="=">
    <constant intConst="3"/>
  </assign>
</variable>
int[] array2=new int[2];
 
<variable name="array2" type="int" array="true">
  <array>
    <constant intConst="2"/>
  </array>
</variable>
double x,y,z;
is:
<variable name="x.y.z"/>
should be:
<declare type=double>x</declare>
         <declare type=double>y</declare>
         <declare type=double>z</declare>

JDK 1.5 allows Generic Types:

ArrayList<Integer> list = new ArrayList<Integer>();

JDK 1.5 also allows enum:

public enum StopLight { red, amber, green };

   
<assign name="list" declare="ArrayList" generic="Integer">
  ArrayList
</assign>
<declare type=enum values="red, amber, green">
  StopLight
</declare>
String values[] = (String []) names;    

<assign name="values" declare="String" array=true>(String []) names</assign>

other possible parameters:

type = "=" default
type = "++pre"
type = "++post"
type = "--pre"
type = "--post"
type = "+="
type = "-="
type = "*="
type = "/="
type = "%="
type = "&="
type = "|="
type = "^="
type = "<<="
type = ">>="
type = "<<<="

       
       

Statements

Java example java1.5.zip tree structure XES tree structure XES
Math.abs(1);
 
 
a++
 
 
++a
   
 
 
   
 
 
   
 
 
   
 
 
   
 
     
 

 

   
 
     

 

       
       

metadata block
see also:
Correspondence about this page

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

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