// deriv3.java //

// An example file explaining how to use // com.stevesoft.pat, com.stevesoft.pat.wrap, // and com.stevesoft.pat.apps //

// This software comes without express or implied warranty. // No claim is made about the suitability of this software for // any purpose and neither I nor SteveSoft shall be liable for // damages suffered by the user of this software. import com.stevesoft.pat.*; // This is the new rule we wish to define... // In this case, balanced grouping symbols. // Thus, "({})" will match, and so will "[}". class Bal extends Validator { public int validate(StringLike src,int start,int end) { // You really shouldn't put print statements here except when // debugging. I'm doing it, however, so you can see what things // validate has to process in the search for a match. System.out.println("validating: >>"+src.substring(0,start)+"|"+ src.substring(start,end)+"|"+src.substring(end,src.length())+"<<"); int count = 0; int m = src.length(); if(m > end) m = end; for(int i=start;i