The goal of this project is to make Snobol4-style pattern matching
available as a package for the Java programming language.
Rather than build such a package from scratch,
Rober Dewar's
existing
Ada-based Gnat Spitbol Patterns code
was converted to Java.
The result is generally consistent with that Ada package, although
some changes were made to conform to the capabilities and
limitations of the Java language. In light of the derived nature of this code,
the original GNAT license is assumed to cover this code.
The compiler, however is licensed under a BSD license.
See the License Section
for more details.
http://www.cs.colorado.edu/~dennis/software
for download information.
In addition, earlier versions may also be available through that page.
Note that the jpattern-x.x.jar file is not itself executable
by java. It must be downloaded and extracted. An executable jar file
(also named jpattern.jar)
is included in the set of extracted files.
Dependencies
- Java -- This interpreter uses features of Java 1.5.
The distribution contains both an ant build.xml file
and a Makefile. Both have the following major tasks defined.
- all: Compile the source and construct the jar file
called
jpattern.jar.
It is assumed that the JDK 1.5 bin directory
is in the PATH environment variable.
- clean: Delete the .class files, the jar file,
and the manifest file.
The final product is the jar file called jpattern.jar.
For convenience, a version of that jar file is included. It has been
compiled with jdk1.5.
A set of tests is provided in the directory name tests.
A make Makefile and an ant build.xml file are both provided.
The output of the tests is captured and compared to the expected output.
Any discrepancies are reported.
The set of tests is rather sketchy; it is derived from various examples
from online, from the snobol4 book, and from bug reports. If anyone knows
of a more comprehensive set of pattern tests, please contact the
author.
The package jpattern.compiler supports the
compilation of string expressions into equivalent Pattern
objects.
It is capable of converting a string representation of a pattern
to equivalent Java code (via a command line interface)
or
to a Pattern object at runtime (via an API).
Refer to the reference manual for more details.
Minor version levels are indicated in parentheses.
- (0) This is the initial release
- (1) Modified the licensing to conform to Robert Dewar's request.
- (1) Changed the -java flag to be -tag.
- (1) Added the -xmltag flag.
- (2) Added a manifest to jpattern.jar so it can be used in compiler mode.
- (2) Modified the distribution to include a pre-compiled jpattern.jar.
Minor version levels are indicated in parentheses.
- (0) Fixed a number of foolish errors, some introduced in version 1.2
(Thanks to Arjan Loeffen of Valid/Vision.). These include:
- The pattern fence(arb & "b") & "c"
matched against subject "b" throws
java.lang.ArrayIndexOutOfBoundsException: -2147483647 , while
fence(arb & "b") doesn't.
- The pattern len(1) fails on subject "a".
- The pattern "a" ** MATCH on subject "a"
throws java.lang.ArrayIndexOutOfBoundsException: -2147483647.
- The pattern bal("()") doesn't seem to work, while bal does.
- (0) Modified the test set files to all extend Test.java to handle
the common code.
- (0) Did some significant refactoring.
- (0) Fixed errors in ParseArgs.java that did not handle missing
arguments correctly.
- (0) Added backquote strings to pass through Java expressions
for use during pattern construction.
- (0) Replaced the Function mechanism with a somewhat more general
ExternalVariable mechanism.
- (0) Added an ExternalPattern mechanism to support user defined
pattern objects in matching.
- (0) Divided doc/jpattern.html into jpattern.html and refman.html.
- (0) The structure of the classes and their use has been
modified to look more like the java.util.regex structure.
- (0) The test cases have been moved from package jpattern.test
to test so that they do not have implicit access
to the jpattern package, thus being able to expose access errors.