import java.util.*;

public class Matcher
{
    public Matcher (Rule[] rules, boolean debug)
    {
        _rules = rules;
        _debug = debug;
    }

    public Message[] matchRule (int ruleNumber, Message[] messages)
    {
        Rule ruleToMatch = _rules[ruleNumber];
        Vector<Message> toMatch = new Vector<Message>();

        //if (_debug)
            System.out.println("Trying to match rule: "+ruleToMatch);

        String current = getMatchingString(ruleToMatch, "");

        System.out.println("Match using first rules: "+current);

        toMatch.add(new Message(current));

        return null;
    }

    public void expandRule (int ruleNumber)
    {
        Rule ruleToMatch = _rules[ruleNumber];
    }

    // try first rule set only.
    
    private String getMatchingString (Rule theRule, String current)
    {
        String str = current;

        System.out.println("Looking to match "+theRule.getNumber());

        if (!theRule.isCharacterRule())
        {
            int[] firstRules = theRule.firstDependantRules();

            for (int i = 0; i < firstRules.length; i++)
            {
                str = getMatchingString(_rules[firstRules[i]], str);

                //if (_debug)
                    System.out.println("First rules string: "+str);
            }
        }
        else
            str += theRule.getMatch();

        System.out.println("\n**returning "+str);

        return str;
    }

    private Rule[] _rules;
    private boolean _debug;
}
@@ -634,12 +634,14 @@
 lic 
-void
+String
  exp
@@ -714,24 +714,192 @@
 uleNumber%5D;%0A
+        String str = %22%22;%0A%0A        if (ruleToMatch.isCharacterRule())%0A            str = %22%22+ruleToMatch.getMatch();%0A        else%0A        %7B%0A        %7D%0A%0A        return str;%0A
     %7D%0A%0A    /
@@ -1173,20 +1173,19 @@
   int%5B%5D 
-firs
+lef
 tRules =
@@ -1197,21 +1197,11 @@
 ule.
-firstDependan
+lef
 tRul
@@ -1239,20 +1239,19 @@
  0; i %3C 
-firs
+lef
 tRules.l
@@ -1323,20 +1323,19 @@
 (_rules%5B
-firs
+lef
 tRules%5Bi

Update Matcher.java