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"/>
int var2 =2;
<variable name="var1" type="int">
  <assign operator="=">
    <constant intConst="2"/>
int[] array1;
<variable name="array1" type="int" array="true"/>
array1 = new int[1];
<variable name="array1">
  <assign operator="=">
      <constant intConst="1"/>
<variable name="array1">
    <constant intConst="0"/>
  <assign operator="=">
    <constant intConst="3"/>
int[] array2=new int[2];
<variable name="array2" type="int" array="true">
    <constant intConst="2"/>
double x,y,z;
<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">
<declare type=enum values="red, amber, green">
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 = "<<<="



Java example java1.5.zip tree structure XES tree structure XES





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.