01: /*
02: * TclRegexp.java
03: *
04: * Copyright (c) 1999 Sun Microsystems, Inc.
05: *
06: * See the file "license.terms" for information on usage and
07: * redistribution of this file, and for a DISCLAIMER OF ALL
08: * WARRANTIES.
09: *
10: * SCCS: %Z% %M% %I% %E% %U%
11: */
12:
13: package tcl.lang;
14:
15: import sunlabs.brazil.util.regexp.Regexp;
16:
17: public class TclRegexp {
18: private TclRegexp() {
19: }
20:
21: public static Regexp compile(Interp interp, TclObject exp,
22: boolean nocase) throws TclException {
23: try {
24: return new Regexp(exp.toString(), nocase);
25: } catch (IllegalArgumentException e) {
26: String msg = e.getMessage();
27: if (msg.equals("missing )")) {
28: msg = "unmatched ()";
29: } else if (msg.equals("missing ]")) {
30: msg = "unmatched []";
31: }
32: msg = "couldn't compile regular expression pattern: " + msg;
33: throw new TclException(interp, msg);
34: }
35: }
36: }
|