From e9271f470a5c61562d40b4ecf2fbeef123ac127a Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 11 Sep 2017 17:50:19 -0700 Subject: Start work on implementation of CL format --- BJC-Utils2/data/formats.sprop | 24 ++++++++++++++++++++++ BJC-Utils2/data/regexes.sprop | 16 +++++++++++++++ .../main/java/bjc/utils/ioutils/CLFormatter.java | 14 +++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 BJC-Utils2/src/main/java/bjc/utils/ioutils/CLFormatter.java diff --git a/BJC-Utils2/data/formats.sprop b/BJC-Utils2/data/formats.sprop index 7d8fc94..73ebc29 100644 --- a/BJC-Utils2/data/formats.sprop +++ b/BJC-Utils2/data/formats.sprop @@ -1,5 +1,29 @@ # File storage for format strings +################################################# +# Generic format strings for regular expressions. +################################################# + +## Format a regular expression for matching a delimiter separated list. +## Takes two parameters +## 1) The expression for each term +## 2) The expression for the delimiter +delimSeparatedList (?:%1$s(?:%2$s%1$s)*) + +###################################### +# CL format string regular expressions +###################################### + +## Format a regular expression for matching a potential CL format directive +## Has two parts +## 1) The optional set of prefix parameters +## 2) The optional modifier +## Captures three things +## 1) The prefix parameters +## 2) The modifiers +## 3) The directive name +clFormatDirective ~(?%1$s)?(?%2$s?)(?\S) + #################################################### # Format strings for handling double-quoted strings. #################################################### diff --git a/BJC-Utils2/data/regexes.sprop b/BJC-Utils2/data/regexes.sprop index cdacea0..dadc09c 100644 --- a/BJC-Utils2/data/regexes.sprop +++ b/BJC-Utils2/data/regexes.sprop @@ -34,6 +34,22 @@ fpExponent [eE][+-]? ## NOTE: The incomplete parts are finished by where it is inserted. fpLeader [\x00-\x20]*[+-]?(?:NaN|Infinity| +###################################### +# CL format string regular expressions +###################################### + +## Matches a format string prefix parameter +## A prefix parameter is one of +## * A signed decimal number +## * A single character preceded by a single quote +## * The letter V (or v) +## * The character # +clFormatPrefix (?:[-+]?\d+|'\S|[Vv]|#) + +## Match a format string modifier +## A modifier is either : or @, or both in either order +clFormatModifier (?:@|:|@:|:@) + ############################################## # Miscellaneous validation regular expressions ############################################## diff --git a/BJC-Utils2/src/main/java/bjc/utils/ioutils/CLFormatter.java b/BJC-Utils2/src/main/java/bjc/utils/ioutils/CLFormatter.java new file mode 100644 index 0000000..a119c9b --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/ioutils/CLFormatter.java @@ -0,0 +1,14 @@ +package bjc.utils.ioutils; + +import bjc.utils.PropertyDB; + +import static bjc.utils.PropertyDB.applyFormat; +import static bjc.utils.PropertyDB.getCompiledRegex; +import static bjc.utils.PropertyDB.getRegex; + +import java.util.regex.Pattern; + +public class CLFormatter { + private static final String prefixParam = getRegex("clFormatPrefix"); + private static final Pattern pPrefixParam = Pattern.compile(prefixParam); +} -- cgit v1.2.3