From c6897211cb5da8c5bbbaf267db8ad020eb63a114 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 9 Sep 2019 19:56:53 -0400 Subject: Implement pattern guards Pattern guards allow you to say that a particular pair should only be replaced when the input matches a particular regular expression. It is tied to the 'G' or 'Guard' control on the pair header, and is one of the 3 or so major features I want to implement before a 1.0 release As an aside, the other two features I want to add are: Multibody Support ================= This will allow a pair to replace to a few different things, based on various conditions (the two main ones I want are some sort of cyclic behavior, and some sort of guards for these) Sub-application ================ Allow the application of a stage to the result of applying a pair/parts of applying a pair. This will likely entail several sub-features such as: Named Stages ------------ A named stage is a collection of pairs that isn't applied by default, but is instead used for convenient grouping of related pages together. Custom Replacement ------------------ Instead of using replaceAll, I'll probably go for something using appendReplacement etc. on Matcher and roll some sort of custom thing, so as to provide for a convenient syntax for anything special I want to do while running the replacement. I'll also want to add some documentation, in addition to maybe doing some restructuring to make how things are laid out more obvious. --- src/test/java/bjc/everge/ReplPairTest.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/test') diff --git a/src/test/java/bjc/everge/ReplPairTest.java b/src/test/java/bjc/everge/ReplPairTest.java index 8edb42e..e098605 100644 --- a/src/test/java/bjc/everge/ReplPairTest.java +++ b/src/test/java/bjc/everge/ReplPairTest.java @@ -86,4 +86,9 @@ public class ReplPairTest { public void testGlobals() { assertMultiReplace("data/test/test8.rp", "b1d\n1d\n1b1", "acca"); } + + @Test + public void testGuards() { + assertMultiReplace("data/test/test10.rp", "a", "a", "bbb", "aaa"); + } } -- cgit v1.2.3