`TITextProcessing` for regex and text formatting added

This commit is contained in:
Vladimir Makarov 2023-04-18 19:24:16 +03:00
parent 5a14c61a9a
commit 93a8ee68f3
41 changed files with 10350 additions and 25 deletions

View File

@ -1,5 +1,9 @@
# Changelog
### 1.43.0
- **Added**: `TITextProcessing` for regex and text formatting added
### 1.42.1
- **Fixed**: Podspecs source and homepage urls

View File

@ -9,6 +9,15 @@
"version" : "5.4.3"
}
},
{
"identity" : "antlr4",
"kind" : "remoteSourceControl",
"location" : "https://github.com/antlr/antlr4",
"state" : {
"revision" : "44d87bc1d130c88aa452894aa5f7e2f710f68253",
"version" : "4.10.1"
}
},
{
"identity" : "cache",
"kind" : "remoteSourceControl",

View File

@ -40,9 +40,8 @@ let package = Package(
.library(name: "TITransitions", targets: ["TITransitions"]),
.library(name: "TIPagination", targets: ["TIPagination"]),
.library(name: "TIAuth", targets: ["TIAuth"]),
//MARK: - Skolkovo
.library(name: "TIEcommerce", targets: ["TIEcommerce"])
.library(name: "TIEcommerce", targets: ["TIEcommerce"]),
.library(name: "TITextProcessing", targets: ["TITextProcessing"])
],
dependencies: [
.package(url: "https://github.com/maxsokolov/TableKit.git", .upToNextMajor(from: "2.11.0")),
@ -50,7 +49,8 @@ let package = Package(
.package(url: "https://github.com/petropavel13/Cursors", .upToNextMajor(from: "0.5.1")),
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.4.0")),
.package(url: "https://github.com/Moya/Moya.git", .upToNextMajor(from: "15.0.0")),
.package(url: "https://github.com/hyperoslo/Cache.git", .upToNextMajor(from: "6.0.0"))
.package(url: "https://github.com/hyperoslo/Cache.git", .upToNextMajor(from: "6.0.0")),
.package(url: "https://github.com/antlr/antlr4", .upToNextMinor(from: "4.10.1"))
],
targets: [
@ -85,12 +85,17 @@ let package = Package(
.target(name: "TIPagination", dependencies: ["Cursors", "TISwiftUtils"], path: "TIPagination/Sources"),
.target(name: "TIAuth", dependencies: ["TIFoundationUtils", "TIUIKitCore", "KeychainAccess"], path: "TIAuth/Sources"),
.target(name: "TIEcommerce", dependencies: ["TIFoundationUtils", "TISwiftUtils", "TINetworking", "TIUIKitCore", "TIUIElements"], path: "TIEcommerce/Sources"),
.target(name: "TITextProcessing", dependencies: [.product(name: "Antlr4", package: "antlr4")], path: "TITextProcessing/Sources"),
// MARK: - Tests
.testTarget(
name: "TITimerTests",
dependencies: ["TIFoundationUtils"],
path: "Tests/TITimerTests"),
.testTarget(
name: "TITextProcessingTests",
dependencies: ["TITextProcessing"],
path: "Tests/TITextProcessingTests")
]
)

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIAppleMapUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Apple MapKit.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIAuth'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Login, registration, confirmation and other related actions'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIDeeplink'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Deeplink service API'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIDeveloperUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Universal web view API'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIEcommerce'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Cart, products, promocodes, bonuses and other related actions'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIFoundationUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for Foundation framework classes.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIGoogleMapUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Google Maps SDK.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIKeychainUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for Keychain classes.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIMapUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for map objects clustering and interacting.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIMoyaNetworking'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Moya + Swagger network service.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TINetworking'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Swagger-frendly networking layer helpers.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TINetworkingCache'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Caching results of EndpointRequests.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIPagination'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Generic pagination component.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TISwiftUICore'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Core UI elements: protocols, views and helpers.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TISwiftUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Bunch of useful helpers for Swift development.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TITableKitUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for TableKit classes.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -0,0 +1,98 @@
# `TITextProcessing`
### Библиотека для работы с регулярными выражениями
## - `TextFormatter`
Класс `TextFormatter` представляет из себя сервис, принимающий регулярное выражение на вход и предоставляющий возможность генерации следующих объектов:
\- `Replacement template` из `getRegexReplacement()`;
\- `Placeholder` из `getRegexPlaceholder()`;
\- `Formatter text` из `getFormattedText(_ text: String)`
#### `func getRegexReplacement()`
Метод, преобразующий входящее регулярное выражение в шаблон подстановки, например:
**Input**: `(\\d{4}) ?(\\d{4}) ?(\\d{4}) ?(\\d{4})`<br>
**Output**: `$1 $2 $3 $4`
#### `func getRegexPlaceholder()`
Метод, преобразующий входящее регулярное выражение в текст-заполнитесь a.k.a placeholder, например:
**Input**: `(\\d{4}) ?(\\d{4}) ?(\\d{4}) ?(\\d{4})`<br>
**Output**: `1234 5678 9012 3456`
#### `func getFormattedText(_ text: String) -> String`
Метод, преобразующий входящий текст к нужному формату, заранее определенному посредством указания регулярного выражения, например:
**Input**: `2200111555550080`<br>
**Output**: `2200 1115 5555 0080`
> P.S. Учитываем, что `TextFormatter` был проинициализирован со слеюущим регулярным выражением: `(\\d{4}) ?(\\d{4}) ?(\\d{4}) ?(\\d{4})`
## - `RegexReplaceGenerator`
Класс, отвечающий за генерацию `PCREGeneratorItem` из входящего регулярного выражения. Использует библиотеку `Antlr4` и `PCRE` для работы.
#### `static func generateReplacement(for regex: String) -> PCREGeneratorItem`
Функция, преобразующий входящее регулярное выражение в структуру, содержащую шаблон подстановки и матрицу символов, например:
```swift
let item = RegexReplaceGenerator. generateReplacement(for: "(\\d{2})\\/?(\\d{2})")
print(item.regexReplaceString)
/*
Выведет в консоль:
"$1\\/$2"
*/
print(item.matrixOfSymbols)
/*
Выведет в консоль:
[
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["/"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
]
*/
```
Итоговый `PCREGeneratorItem` содержит следующие данные:
`regexReplaceString` - итоговый шаблон подстановки для изначального регулярного выражения;<br>
`matrixOfSymbols` - матрица символов, содержащая все возможные символы для каждого элемента в изначальном регулярном выражении
## - `RegexPlaceholderGenerator`
Класс, отвечающий за генерацию текста-заполнителя a.k.a placeholder.
#### `static func generatePlaceholder(matrixOfSymbols: [[Character]]) -> String`
Функция, преобразующая входящую матрицу символов в текст-заполнитель, например:
```swift
let matrix: [[Character]] = [
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["/"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
]
let placeholder = RegexPlaceholderGenerator.generatePlaceholder(matrixOfSymbols: matrix)
print(placeholder)
/*
Выведет в консоль:
"12/34"
*/
```

View File

@ -0,0 +1,754 @@
/*
* Copyright (c) 2014-2022 by Bart Kiers
*
* The MIT license.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Project : PCRE Parser, an ANTLR 4 grammar for PCRE
* Developed by : Bart Kiers, bart@big-o.nl
* Also see : https://github.com/bkiers/pcre-parser
*/
grammar PCRE;
// Most single line comments above the lexer- and parser rules
// are copied from the official PCRE man pages (last updated:
// 10 January 2012): http://www.pcre.org/pcre.txt
parse
: alternation EOF
;
// ALTERNATION
//
// expr|expr|expr...
alternation
: expr ('|' expr)*
;
expr
: element*
;
element
: atom quantifier?
;
// QUANTIFIERS
//
// ? 0 or 1, greedy
// ?+ 0 or 1, possessive
// ?? 0 or 1, lazy
// * 0 or more, greedy
// *+ 0 or more, possessive
// *? 0 or more, lazy
// + 1 or more, greedy
// ++ 1 or more, possessive
// +? 1 or more, lazy
// {n} exactly n
// {n,m} at least n, no more than m, greedy
// {n,m}+ at least n, no more than m, possessive
// {n,m}? at least n, no more than m, lazy
// {n,} n or more, greedy
// {n,}+ n or more, possessive
// {n,}? n or more, lazy
quantifier
: '?' quantifier_type
| '+' quantifier_type
| '*' quantifier_type
| '{' number '}' quantifier_type
| '{' number ',' '}' quantifier_type
| '{' number ',' number '}' quantifier_type
;
quantifier_type
: '+'
| '?'
| /* nothing */
;
// CHARACTER CLASSES
//
// [...] positive character class
// [^...] negative character class
// [x-y] range (can be used for hex characters)
// [[:xxx:]] positive POSIX named set
// [[:^xxx:]] negative POSIX named set
//
// alnum alphanumeric
// alpha alphabetic
// ascii 0-127
// blank space or tab
// cntrl control character
// digit decimal digit
// graph printing, excluding space
// lower lower case letter
// print printing, including space
// punct printing, excluding alphanumeric
// space white space
// upper upper case letter
// word same as \w
// xdigit hexadecimal digit
//
// In PCRE, POSIX character set names recognize only ASCII characters by
// default, but some of them use Unicode properties if PCRE_UCP is set.
// You can use \Q...\E inside a character class.
character_class
: '[' '^' CharacterClassEnd Hyphen cc_atom+ ']'
| '[' '^' CharacterClassEnd cc_atom* ']'
| '[' '^' cc_atom+ ']'
| '[' CharacterClassEnd Hyphen cc_atom+ ']'
| '[' CharacterClassEnd cc_atom* ']'
| '[' cc_atom+ ']'
;
// BACKREFERENCES
//
// \n reference by number (can be ambiguous)
// \gn reference by number
// \g{n} reference by number
// \g{-n} relative reference by number
// \k<name> reference by name (Perl)
// \k'name' reference by name (Perl)
// \g{name} reference by name (Perl)
// \k{name} reference by name (.NET)
// (?P=name) reference by name (Python)
backreference
: backreference_or_octal
| '\\g' number
| '\\g' '{' number '}'
| '\\g' '{' '-' number '}'
| '\\k' '<' name '>'
| '\\k' '\'' name '\''
| '\\g' '{' name '}'
| '\\k' '{' name '}'
| '(' '?' 'P' '=' name ')'
;
backreference_or_octal
: octal_char
| Backslash digit
;
// CAPTURING
//
// (...) capturing group
// (?<name>...) named capturing group (Perl)
// (?'name'...) named capturing group (Perl)
// (?P<name>...) named capturing group (Python)
// (?:...) non-capturing group
// (?|...) non-capturing group; reset group numbers for
// capturing groups in each alternative
//
// ATOMIC GROUPS
//
// (?>...) atomic, non-capturing group
capture
: '(' '?' '<' name '>' alternation ')'
| '(' '?''\'' name '\'' alternation ')'
| '(' '?' 'P' '<' name '>' alternation ')'
| '(' alternation ')'
;
non_capture
: '(' '?' ':' alternation ')'
| '(' '?' '|' alternation ')'
| '(' '?' '>' alternation ')'
| '(' '?' option_flags ':' alternation ')'
;
// COMMENT
//
// (?#....) comment (not nestable)
comment
: '(' '?' '#' non_close_parens ')'
;
// OPTION SETTING
//
// (?i) caseless
// (?J) allow duplicate names
// (?m) multiline
// (?s) single line (dotall)
// (?U) default ungreedy (lazy)
// (?x) extended (ignore white space)
// (?-...) unset option(s)
//
// The following are recognized only at the start of a pattern or after
// one of the newline-setting options with similar syntax:
//
// (*NO_START_OPT) no start-match optimization (PCRE_NO_START_OPTIMIZE)
// (*UTF8) set UTF-8 mode: 8-bit library (PCRE_UTF8)
// (*UTF16) set UTF-16 mode: 16-bit library (PCRE_UTF16)
// (*UCP) set PCRE_UCP (use Unicode properties for \d etc)
option
: '(' '?' option_flags '-' option_flags ')'
| '(' '?' option_flags ')'
| '(' '?' '-' option_flags ')'
| '(' '*' 'N' 'O' '_' 'S' 'T' 'A' 'R' 'T' '_' 'O' 'P' 'T' ')'
| '(' '*' 'U' 'T' 'F' '8' ')'
| '(' '*' 'U' 'T' 'F' '1' '6' ')'
| '(' '*' 'U' 'C' 'P' ')'
;
option_flags
: option_flag+
;
option_flag
: 'i'
| 'J'
| 'm'
| 's'
| 'U'
| 'x'
;
// LOOKAHEAD AND LOOKBEHIND ASSERTIONS
//
// (?=...) positive look ahead
// (?!...) negative look ahead
// (?<=...) positive look behind
// (?<!...) negative look behind
//
// Each top-level branch of a look behind must be of a fixed length.
look_around
: '(' '?' '=' alternation ')'
| '(' '?' '!' alternation ')'
| '(' '?' '<' '=' alternation ')'
| '(' '?' '<' '!' alternation ')'
;
// SUBROUTINE REFERENCES (POSSIBLY RECURSIVE)
//
// (?R) recurse whole pattern
// (?n) call subpattern by absolute number
// (?+n) call subpattern by relative number
// (?-n) call subpattern by relative number
// (?&name) call subpattern by name (Perl)
// (?P>name) call subpattern by name (Python)
// \g<name> call subpattern by name (Oniguruma)
// \g'name' call subpattern by name (Oniguruma)
// \g<n> call subpattern by absolute number (Oniguruma)
// \g'n' call subpattern by absolute number (Oniguruma)
// \g<+n> call subpattern by relative number (PCRE extension)
// \g'+n' call subpattern by relative number (PCRE extension)
// \g<-n> call subpattern by relative number (PCRE extension)
// \g'-n' call subpattern by relative number (PCRE extension)
subroutine_reference
: '(' '?' 'R' ')'
| '(' '?' number ')'
| '(' '?' '+' number ')'
| '(' '?' '-' number ')'
| '(' '?' '&' name ')'
| '(' '?' 'P' '>' name ')'
| '\\g' '<' name '>'
| '\\g' '\'' name '\''
| '\\g' '<' number '>'
| '\\g' '\'' number '\''
| '\\g' '<' '+' number '>'
| '\\g' '\'' '+' number '\''
| '\\g' '<' '-' number '>'
| '\\g' '\'' '-' number '\''
;
// CONDITIONAL PATTERNS
//
// (?(condition)yes-pattern)
// (?(condition)yes-pattern|no-pattern)
//
// (?(n)... absolute reference condition
// (?(+n)... relative reference condition
// (?(-n)... relative reference condition
// (?(<name>)... named reference condition (Perl)
// (?('name')... named reference condition (Perl)
// (?(name)... named reference condition (PCRE)
// (?(R)... overall recursion condition
// (?(Rn)... specific group recursion condition
// (?(R&name)... specific recursion condition
// (?(DEFINE)... define subpattern for reference
// (?(assert)... assertion condition
conditional
: '(' '?' '(' number ')' alternation ('|' alternation)? ')'
| '(' '?' '(' '+' number ')' alternation ('|' alternation)? ')'
| '(' '?' '(' '-' number ')' alternation ('|' alternation)? ')'
| '(' '?' '(' '<' name '>' ')' alternation ('|' alternation)? ')'
| '(' '?' '(' '\'' name '\'' ')' alternation ('|' alternation)? ')'
| '(' '?' '(' 'R' number ')' alternation ('|' alternation)? ')'
| '(' '?' '(' 'R' ')' alternation ('|' alternation)? ')'
| '(' '?' '(' 'R' '&' name ')' alternation ('|' alternation)? ')'
| '(' '?' '(' 'D' 'E' 'F' 'I' 'N' 'E' ')' alternation ('|' alternation)? ')'
| '(' '?' '(' 'a' 's' 's' 'e' 'r' 't' ')' alternation ('|' alternation)? ')'
| '(' '?' '(' name ')' alternation ('|' alternation)? ')'
;
// BACKTRACKING CONTROL
//
// The following act immediately they are reached:
//
// (*ACCEPT) force successful match
// (*FAIL) force backtrack; synonym (*F)
// (*MARK:NAME) set name to be passed back; synonym (*:NAME)
//
// The following act only when a subsequent match failure causes a back-
// track to reach them. They all force a match failure, but they differ in
// what happens afterwards. Those that advance the start-of-match point do
// so only if the pattern is not anchored.
//
// (*COMMIT) overall failure, no advance of starting point
// (*PRUNE) advance to next starting character
// (*PRUNE:NAME) equivalent to (*MARK:NAME)(*PRUNE)
// (*SKIP) advance to current matching position
// (*SKIP:NAME) advance to position corresponding to an earlier
// (*MARK:NAME); if not found, the (*SKIP) is ignored
// (*THEN) local failure, backtrack to next alternation
// (*THEN:NAME) equivalent to (*MARK:NAME)(*THEN)
backtrack_control
: '(' '*' 'A' 'C' 'C' 'E' 'P' 'T' ')'
| '(' '*' 'F' ('A' 'I' 'L')? ')'
| '(' '*' ('M' 'A' 'R' 'K')? ':' 'N' 'A' 'M' 'E' ')'
| '(' '*' 'C' 'O' 'M' 'M' 'I' 'T' ')'
| '(' '*' 'P' 'R' 'U' 'N' 'E' ')'
| '(' '*' 'P' 'R' 'U' 'N' 'E' ':' 'N' 'A' 'M' 'E' ')'
| '(' '*' 'S' 'K' 'I' 'P' ')'
| '(' '*' 'S' 'K' 'I' 'P' ':' 'N' 'A' 'M' 'E' ')'
| '(' '*' 'T' 'H' 'E' 'N' ')'
| '(' '*' 'T' 'H' 'E' 'N' ':' 'N' 'A' 'M' 'E' ')'
;
// NEWLINE CONVENTIONS
//capture
// These are recognized only at the very start of the pattern or after a
// (*BSR_...), (*UTF8), (*UTF16) or (*UCP) option.
//
// (*CR) carriage return only
// (*LF) linefeed only
// (*CRLF) carriage return followed by linefeed
// (*ANYCRLF) all three of the above
// (*ANY) any Unicode newline sequence
//
// WHAT \R MATCHES
//
// These are recognized only at the very start of the pattern or after a
// (*...) option that sets the newline convention or a UTF or UCP mode.
//
// (*BSR_ANYCRLF) CR, LF, or CRLF
// (*BSR_UNICODE) any Unicode newline sequence
newline_convention
: '(' '*' 'C' 'R' ')'
| '(' '*' 'L' 'F' ')'
| '(' '*' 'C' 'R' 'L' 'F' ')'
| '(' '*' 'A' 'N' 'Y' 'C' 'R' 'L' 'F' ')'
| '(' '*' 'A' 'N' 'Y' ')'
| '(' '*' 'B' 'S' 'R' '_' 'A' 'N' 'Y' 'C' 'R' 'L' 'F' ')'
| '(' '*' 'B' 'S' 'R' '_' 'U' 'N' 'I' 'C' 'O' 'D' 'E' ')'
;
// CALLOUTS
//
// (?C) callout
// (?Cn) callout with data n
callout
: '(' '?' 'C' ')'
| '(' '?' 'C' number ')'
;
atom
: subroutine_reference
| shared_atom
| literal
| character_class
| capture
| non_capture
| comment
| option
| look_around
| backreference
| conditional
| backtrack_control
| newline_convention
| callout
| Dot
| Caret
| StartOfSubject
| WordBoundary
| NonWordBoundary
| EndOfSubjectOrLine
| EndOfSubjectOrLineEndOfSubject
| EndOfSubject
| PreviousMatchInSubject
| ResetStartMatch
| OneDataUnit
| ExtendedUnicodeChar
;
cc_atom
: cc_literal Hyphen cc_literal
| shared_atom
| cc_literal
| backreference_or_octal // only octal is valid in a cc
;
shared_atom
: POSIXNamedSet
| POSIXNegatedNamedSet
| ControlChar
| DecimalDigit
| NotDecimalDigit
| HorizontalWhiteSpace
| NotHorizontalWhiteSpace
| NotNewLine
| CharWithProperty
| CharWithoutProperty
| NewLineSequence
| WhiteSpace
| NotWhiteSpace
| VerticalWhiteSpace
| NotVerticalWhiteSpace
| WordChar
| NotWordChar
| Backslash . // will match "unfinished" escape sequences, like `\x`
;
literal
: shared_literal
| CharacterClassEnd
;
cc_literal
: shared_literal
| Dot
| CharacterClassStart
| Caret
| QuestionMark
| Plus
| Star
| WordBoundary
| EndOfSubjectOrLine
| Pipe
| OpenParen
| CloseParen
;
shared_literal
: octal_char
| letter
| digit
| BellChar
| EscapeChar
| FormFeed
| NewLine
| CarriageReturn
| Tab
| HexChar
| Quoted
| BlockQuoted
| OpenBrace
| CloseBrace
| Comma
| Hyphen
| LessThan
| GreaterThan
| SingleQuote
| Underscore
| Colon
| Hash
| Equals
| Exclamation
| Ampersand
| OtherChar
;
number
: digits
;
octal_char
: ( Backslash (D0 | D1 | D2 | D3) octal_digit octal_digit
| Backslash octal_digit octal_digit
)
;
octal_digit
: D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7
;
digits
: digit+
;
digit
: D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9
;
name
: alpha_nums
;
alpha_nums
: (letter | Underscore) (letter | Underscore | digit)*
;
non_close_parens
: non_close_paren+
;
non_close_paren
: ~CloseParen
;
letter
: ALC | BLC | CLC | DLC | ELC | FLC | GLC | HLC | ILC | JLC | KLC | LLC | MLC | NLC | OLC | PLC | QLC | RLC | SLC | TLC | ULC | VLC | WLC | XLC | YLC | ZLC |
AUC | BUC | CUC | DUC | EUC | FUC | GUC | HUC | IUC | JUC | KUC | LUC | MUC | NUC | OUC | PUC | QUC | RUC | SUC | TUC | UUC | VUC | WUC | XUC | YUC | ZUC
;
// QUOTING
//
// \x where x is non-alphanumeric is a literal x
// \Q...\E treat enclosed characters as literal
Quoted : '\\' NonAlphaNumeric;
BlockQuoted : '\\Q' .*? '\\E';
// CHARACTERS
//
// \a alarm, that is, the BEL character (hex 07)
// \cx "control-x", where x is any ASCII character
// \e escape (hex 1B)
// \f form feed (hex 0C)
// \n newline (hex 0A)
// \r carriage return (hex 0D)
// \t tab (hex 09)
// \ddd character with octal code ddd, or backreference
// \xhh character with hex code hh
// \x{hhh..} character with hex code hhh..
BellChar : '\\a';
ControlChar : '\\c' ASCII;
EscapeChar : '\\e';
FormFeed : '\\f';
NewLine : '\\n';
CarriageReturn : '\\r';
Tab : '\\t';
Backslash : '\\';
HexChar : '\\x' ( HexDigit HexDigit
| '{' HexDigit HexDigit HexDigit+ '}'
)
;
// CHARACTER TYPES
//
// . any character except newline;
// in dotall mode, any character whatsoever
// \C one data unit, even in UTF mode (best avoided)
// \d a decimal digit
// \D a character that is not a decimal digit
// \h a horizontal white space character
// \H a character that is not a horizontal white space character
// \N a character that is not a newline
// \p{xx} a character with the xx property
// \P{xx} a character without the xx property
// \R a newline sequence
// \s a white space character
// \S a character that is not a white space character
// \v a vertical white space character
// \V a character that is not a vertical white space character
// \w a "word" character
// \W a "non-word" character
// \X an extended Unicode sequence
//
// In PCRE, by default, \d, \D, \s, \S, \w, and \W recognize only ASCII
// characters, even in a UTF mode. However, this can be changed by setting
// the PCRE_UCP option.
Dot : '.';
OneDataUnit : '\\C';
DecimalDigit : '\\d';
NotDecimalDigit : '\\D';
HorizontalWhiteSpace : '\\h';
NotHorizontalWhiteSpace : '\\H';
NotNewLine : '\\N';
CharWithProperty : '\\p{' UnderscoreAlphaNumerics '}';
CharWithoutProperty : '\\P{' UnderscoreAlphaNumerics '}';
NewLineSequence : '\\R';
WhiteSpace : '\\s';
NotWhiteSpace : '\\S';
VerticalWhiteSpace : '\\v';
NotVerticalWhiteSpace : '\\V';
WordChar : '\\w';
NotWordChar : '\\W';
ExtendedUnicodeChar : '\\X';
// CHARACTER CLASSES
//
// [...] positive character class
// [^...] negative character class
// [x-y] range (can be used for hex characters)
// [[:xxx:]] positive POSIX named set
// [[:^xxx:]] negative POSIX named set
//
// alnum alphanumeric
// alpha alphabetic
// ascii 0-127
// blank space or tab
// cntrl control character
// digit decimal digit
// graph printing, excluding space
// lower lower case letter
// print printing, including space
// punct printing, excluding alphanumeric
// space white space
// upper upper case letter
// word same as \w
// xdigit hexadecimal digit
//
// In PCRE, POSIX character set names recognize only ASCII characters by
// default, but some of them use Unicode properties if PCRE_UCP is set.
// You can use \Q...\E inside a character class.
CharacterClassStart : '[';
CharacterClassEnd : ']';
Caret : '^';
Hyphen : '-';
POSIXNamedSet : '[[:' AlphaNumerics ':]]';
POSIXNegatedNamedSet : '[[:^' AlphaNumerics ':]]';
QuestionMark : '?';
Plus : '+';
Star : '*';
OpenBrace : '{';
CloseBrace : '}';
Comma : ',';
// ANCHORS AND SIMPLE ASSERTIONS
//
// \b word boundary
// \B not a word boundary
// ^ start of subject
// also after internal newline in multiline mode
// \A start of subject
// $ end of subject
// also before newline at end of subject
// also before internal newline in multiline mode
// \Z end of subject
// also before newline at end of subject
// \z end of subject
// \G first matching position in subject
WordBoundary : '\\b';
NonWordBoundary : '\\B';
StartOfSubject : '\\A';
EndOfSubjectOrLine : '$';
EndOfSubjectOrLineEndOfSubject : '\\Z';
EndOfSubject : '\\z';
PreviousMatchInSubject : '\\G';
// MATCH POINT RESET
//
// \K reset start of match
ResetStartMatch : '\\K';
SubroutineOrNamedReferenceStartG : '\\g';
NamedReferenceStartK : '\\k';
Pipe : '|';
OpenParen : '(';
CloseParen : ')';
LessThan : '<';
GreaterThan : '>';
SingleQuote : '\'';
Underscore : '_';
Colon : ':';
Hash : '#';
Equals : '=';
Exclamation : '!';
Ampersand : '&';
ALC : 'a';
BLC : 'b';
CLC : 'c';
DLC : 'd';
ELC : 'e';
FLC : 'f';
GLC : 'g';
HLC : 'h';
ILC : 'i';
JLC : 'j';
KLC : 'k';
LLC : 'l';
MLC : 'm';
NLC : 'n';
OLC : 'o';
PLC : 'p';
QLC : 'q';
RLC : 'r';
SLC : 's';
TLC : 't';
ULC : 'u';
VLC : 'v';
WLC : 'w';
XLC : 'x';
YLC : 'y';
ZLC : 'z';
AUC : 'A';
BUC : 'B';
CUC : 'C';
DUC : 'D';
EUC : 'E';
FUC : 'F';
GUC : 'G';
HUC : 'H';
IUC : 'I';
JUC : 'J';
KUC : 'K';
LUC : 'L';
MUC : 'M';
NUC : 'N';
OUC : 'O';
PUC : 'P';
QUC : 'Q';
RUC : 'R';
SUC : 'S';
TUC : 'T';
UUC : 'U';
VUC : 'V';
WUC : 'W';
XUC : 'X';
YUC : 'Y';
ZUC : 'Z';
D1 : '1';
D2 : '2';
D3 : '3';
D4 : '4';
D5 : '5';
D6 : '6';
D7 : '7';
D8 : '8';
D9 : '9';
D0 : '0';
OtherChar : . ;
// fragments
fragment UnderscoreAlphaNumerics : ('_' | AlphaNumeric)+;
fragment AlphaNumerics : AlphaNumeric+;
fragment AlphaNumeric : [a-zA-Z0-9];
fragment NonAlphaNumeric : ~[a-zA-Z0-9];
fragment HexDigit : [0-9a-fA-F];
fragment ASCII : [\u0000-\u007F];

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,241 @@
Quoted=1
BlockQuoted=2
BellChar=3
ControlChar=4
EscapeChar=5
FormFeed=6
NewLine=7
CarriageReturn=8
Tab=9
Backslash=10
HexChar=11
Dot=12
OneDataUnit=13
DecimalDigit=14
NotDecimalDigit=15
HorizontalWhiteSpace=16
NotHorizontalWhiteSpace=17
NotNewLine=18
CharWithProperty=19
CharWithoutProperty=20
NewLineSequence=21
WhiteSpace=22
NotWhiteSpace=23
VerticalWhiteSpace=24
NotVerticalWhiteSpace=25
WordChar=26
NotWordChar=27
ExtendedUnicodeChar=28
CharacterClassStart=29
CharacterClassEnd=30
Caret=31
Hyphen=32
POSIXNamedSet=33
POSIXNegatedNamedSet=34
QuestionMark=35
Plus=36
Star=37
OpenBrace=38
CloseBrace=39
Comma=40
WordBoundary=41
NonWordBoundary=42
StartOfSubject=43
EndOfSubjectOrLine=44
EndOfSubjectOrLineEndOfSubject=45
EndOfSubject=46
PreviousMatchInSubject=47
ResetStartMatch=48
SubroutineOrNamedReferenceStartG=49
NamedReferenceStartK=50
Pipe=51
OpenParen=52
CloseParen=53
LessThan=54
GreaterThan=55
SingleQuote=56
Underscore=57
Colon=58
Hash=59
Equals=60
Exclamation=61
Ampersand=62
ALC=63
BLC=64
CLC=65
DLC=66
ELC=67
FLC=68
GLC=69
HLC=70
ILC=71
JLC=72
KLC=73
LLC=74
MLC=75
NLC=76
OLC=77
PLC=78
QLC=79
RLC=80
SLC=81
TLC=82
ULC=83
VLC=84
WLC=85
XLC=86
YLC=87
ZLC=88
AUC=89
BUC=90
CUC=91
DUC=92
EUC=93
FUC=94
GUC=95
HUC=96
IUC=97
JUC=98
KUC=99
LUC=100
MUC=101
NUC=102
OUC=103
PUC=104
QUC=105
RUC=106
SUC=107
TUC=108
UUC=109
VUC=110
WUC=111
XUC=112
YUC=113
ZUC=114
D1=115
D2=116
D3=117
D4=118
D5=119
D6=120
D7=121
D8=122
D9=123
D0=124
OtherChar=125
'\\a'=3
'\\e'=5
'\\f'=6
'\\n'=7
'\\r'=8
'\\t'=9
'\\'=10
'.'=12
'\\C'=13
'\\d'=14
'\\D'=15
'\\h'=16
'\\H'=17
'\\N'=18
'\\R'=21
'\\s'=22
'\\S'=23
'\\v'=24
'\\V'=25
'\\w'=26
'\\W'=27
'\\X'=28
'['=29
']'=30
'^'=31
'-'=32
'?'=35
'+'=36
'*'=37
'{'=38
'}'=39
','=40
'\\b'=41
'\\B'=42
'\\A'=43
'$'=44
'\\Z'=45
'\\z'=46
'\\G'=47
'\\K'=48
'\\g'=49
'\\k'=50
'|'=51
'('=52
')'=53
'<'=54
'>'=55
'\''=56
'_'=57
':'=58
'#'=59
'='=60
'!'=61
'&'=62
'a'=63
'b'=64
'c'=65
'd'=66
'e'=67
'f'=68
'g'=69
'h'=70
'i'=71
'j'=72
'k'=73
'l'=74
'm'=75
'n'=76
'o'=77
'p'=78
'q'=79
'r'=80
's'=81
't'=82
'u'=83
'v'=84
'w'=85
'x'=86
'y'=87
'z'=88
'A'=89
'B'=90
'C'=91
'D'=92
'E'=93
'F'=94
'G'=95
'H'=96
'I'=97
'J'=98
'K'=99
'L'=100
'M'=101
'N'=102
'O'=103
'P'=104
'Q'=105
'R'=106
'S'=107
'T'=108
'U'=109
'V'=110
'W'=111
'X'=112
'Y'=113
'Z'=114
'1'=115
'2'=116
'3'=117
'4'=118
'5'=119
'6'=120
'7'=121
'8'=122
'9'=123
'0'=124

View File

@ -0,0 +1,518 @@
// Generated from java-escape by ANTLR 4.11.1
import Antlr4
/**
* This class provides an empty implementation of {@link PCREListener},
* which can be extended to create a listener which only needs to handle a subset
* of the available methods.
*/
open class PCREBaseListener: PCREListener {
public init() { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterParse(_ ctx: PCREParser.ParseContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitParse(_ ctx: PCREParser.ParseContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterAlternation(_ ctx: PCREParser.AlternationContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitAlternation(_ ctx: PCREParser.AlternationContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterExpr(_ ctx: PCREParser.ExprContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitExpr(_ ctx: PCREParser.ExprContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterElement(_ ctx: PCREParser.ElementContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitElement(_ ctx: PCREParser.ElementContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterQuantifier(_ ctx: PCREParser.QuantifierContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitQuantifier(_ ctx: PCREParser.QuantifierContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterQuantifier_type(_ ctx: PCREParser.Quantifier_typeContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitQuantifier_type(_ ctx: PCREParser.Quantifier_typeContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterCharacter_class(_ ctx: PCREParser.Character_classContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitCharacter_class(_ ctx: PCREParser.Character_classContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterBackreference(_ ctx: PCREParser.BackreferenceContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitBackreference(_ ctx: PCREParser.BackreferenceContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterBackreference_or_octal(_ ctx: PCREParser.Backreference_or_octalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitBackreference_or_octal(_ ctx: PCREParser.Backreference_or_octalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterCapture(_ ctx: PCREParser.CaptureContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitCapture(_ ctx: PCREParser.CaptureContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterNon_capture(_ ctx: PCREParser.Non_captureContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitNon_capture(_ ctx: PCREParser.Non_captureContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterComment(_ ctx: PCREParser.CommentContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitComment(_ ctx: PCREParser.CommentContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterOption(_ ctx: PCREParser.OptionContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitOption(_ ctx: PCREParser.OptionContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterOption_flags(_ ctx: PCREParser.Option_flagsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitOption_flags(_ ctx: PCREParser.Option_flagsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterOption_flag(_ ctx: PCREParser.Option_flagContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitOption_flag(_ ctx: PCREParser.Option_flagContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterLook_around(_ ctx: PCREParser.Look_aroundContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitLook_around(_ ctx: PCREParser.Look_aroundContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterSubroutine_reference(_ ctx: PCREParser.Subroutine_referenceContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitSubroutine_reference(_ ctx: PCREParser.Subroutine_referenceContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterConditional(_ ctx: PCREParser.ConditionalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitConditional(_ ctx: PCREParser.ConditionalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterBacktrack_control(_ ctx: PCREParser.Backtrack_controlContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitBacktrack_control(_ ctx: PCREParser.Backtrack_controlContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterNewline_convention(_ ctx: PCREParser.Newline_conventionContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitNewline_convention(_ ctx: PCREParser.Newline_conventionContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterCallout(_ ctx: PCREParser.CalloutContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitCallout(_ ctx: PCREParser.CalloutContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterAtom(_ ctx: PCREParser.AtomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitAtom(_ ctx: PCREParser.AtomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterCc_atom(_ ctx: PCREParser.Cc_atomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitCc_atom(_ ctx: PCREParser.Cc_atomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterShared_atom(_ ctx: PCREParser.Shared_atomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitShared_atom(_ ctx: PCREParser.Shared_atomContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterLiteral(_ ctx: PCREParser.LiteralContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitLiteral(_ ctx: PCREParser.LiteralContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterCc_literal(_ ctx: PCREParser.Cc_literalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitCc_literal(_ ctx: PCREParser.Cc_literalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterShared_literal(_ ctx: PCREParser.Shared_literalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitShared_literal(_ ctx: PCREParser.Shared_literalContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterNumber(_ ctx: PCREParser.NumberContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitNumber(_ ctx: PCREParser.NumberContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterOctal_char(_ ctx: PCREParser.Octal_charContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitOctal_char(_ ctx: PCREParser.Octal_charContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterOctal_digit(_ ctx: PCREParser.Octal_digitContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitOctal_digit(_ ctx: PCREParser.Octal_digitContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterDigits(_ ctx: PCREParser.DigitsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitDigits(_ ctx: PCREParser.DigitsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterDigit(_ ctx: PCREParser.DigitContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitDigit(_ ctx: PCREParser.DigitContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterName(_ ctx: PCREParser.NameContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitName(_ ctx: PCREParser.NameContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterAlpha_nums(_ ctx: PCREParser.Alpha_numsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitAlpha_nums(_ ctx: PCREParser.Alpha_numsContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterNon_close_parens(_ ctx: PCREParser.Non_close_parensContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitNon_close_parens(_ ctx: PCREParser.Non_close_parensContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterNon_close_paren(_ ctx: PCREParser.Non_close_parenContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitNon_close_paren(_ ctx: PCREParser.Non_close_parenContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterLetter(_ ctx: PCREParser.LetterContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitLetter(_ ctx: PCREParser.LetterContext) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func enterEveryRule(_ ctx: ParserRuleContext) throws { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func exitEveryRule(_ ctx: ParserRuleContext) throws { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func visitTerminal(_ node: TerminalNode) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
open func visitErrorNode(_ node: ErrorNode) { }
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,349 @@
// Generated from java-escape by ANTLR 4.11.1
import Antlr4
open class PCRELexer: Lexer {
internal static var _decisionToDFA: [DFA] = {
var decisionToDFA = [DFA]()
let length = PCRELexer._ATN.getNumberOfDecisions()
for i in 0..<length {
decisionToDFA.append(DFA(PCRELexer._ATN.getDecisionState(i)!, i))
}
return decisionToDFA
}()
internal static let _sharedContextCache = PredictionContextCache()
public
static let Quoted=1, BlockQuoted=2, BellChar=3, ControlChar=4, EscapeChar=5,
FormFeed=6, NewLine=7, CarriageReturn=8, Tab=9, Backslash=10,
HexChar=11, Dot=12, OneDataUnit=13, DecimalDigit=14, NotDecimalDigit=15,
HorizontalWhiteSpace=16, NotHorizontalWhiteSpace=17, NotNewLine=18,
CharWithProperty=19, CharWithoutProperty=20, NewLineSequence=21,
WhiteSpace=22, NotWhiteSpace=23, VerticalWhiteSpace=24, NotVerticalWhiteSpace=25,
WordChar=26, NotWordChar=27, ExtendedUnicodeChar=28, CharacterClassStart=29,
CharacterClassEnd=30, Caret=31, Hyphen=32, POSIXNamedSet=33,
POSIXNegatedNamedSet=34, QuestionMark=35, Plus=36, Star=37,
OpenBrace=38, CloseBrace=39, Comma=40, WordBoundary=41, NonWordBoundary=42,
StartOfSubject=43, EndOfSubjectOrLine=44, EndOfSubjectOrLineEndOfSubject=45,
EndOfSubject=46, PreviousMatchInSubject=47, ResetStartMatch=48,
SubroutineOrNamedReferenceStartG=49, NamedReferenceStartK=50,
Pipe=51, OpenParen=52, CloseParen=53, LessThan=54, GreaterThan=55,
SingleQuote=56, Underscore=57, Colon=58, Hash=59, Equals=60,
Exclamation=61, Ampersand=62, ALC=63, BLC=64, CLC=65, DLC=66,
ELC=67, FLC=68, GLC=69, HLC=70, ILC=71, JLC=72, KLC=73, LLC=74,
MLC=75, NLC=76, OLC=77, PLC=78, QLC=79, RLC=80, SLC=81, TLC=82,
ULC=83, VLC=84, WLC=85, XLC=86, YLC=87, ZLC=88, AUC=89, BUC=90,
CUC=91, DUC=92, EUC=93, FUC=94, GUC=95, HUC=96, IUC=97, JUC=98,
KUC=99, LUC=100, MUC=101, NUC=102, OUC=103, PUC=104, QUC=105,
RUC=106, SUC=107, TUC=108, UUC=109, VUC=110, WUC=111, XUC=112,
YUC=113, ZUC=114, D1=115, D2=116, D3=117, D4=118, D5=119, D6=120,
D7=121, D8=122, D9=123, D0=124, OtherChar=125
public
static let channelNames: [String] = [
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
]
public
static let modeNames: [String] = [
"DEFAULT_MODE"
]
public
static let ruleNames: [String] = [
"Quoted", "BlockQuoted", "BellChar", "ControlChar", "EscapeChar", "FormFeed",
"NewLine", "CarriageReturn", "Tab", "Backslash", "HexChar", "Dot", "OneDataUnit",
"DecimalDigit", "NotDecimalDigit", "HorizontalWhiteSpace", "NotHorizontalWhiteSpace",
"NotNewLine", "CharWithProperty", "CharWithoutProperty", "NewLineSequence",
"WhiteSpace", "NotWhiteSpace", "VerticalWhiteSpace", "NotVerticalWhiteSpace",
"WordChar", "NotWordChar", "ExtendedUnicodeChar", "CharacterClassStart",
"CharacterClassEnd", "Caret", "Hyphen", "POSIXNamedSet", "POSIXNegatedNamedSet",
"QuestionMark", "Plus", "Star", "OpenBrace", "CloseBrace", "Comma", "WordBoundary",
"NonWordBoundary", "StartOfSubject", "EndOfSubjectOrLine", "EndOfSubjectOrLineEndOfSubject",
"EndOfSubject", "PreviousMatchInSubject", "ResetStartMatch", "SubroutineOrNamedReferenceStartG",
"NamedReferenceStartK", "Pipe", "OpenParen", "CloseParen", "LessThan",
"GreaterThan", "SingleQuote", "Underscore", "Colon", "Hash", "Equals",
"Exclamation", "Ampersand", "ALC", "BLC", "CLC", "DLC", "ELC", "FLC",
"GLC", "HLC", "ILC", "JLC", "KLC", "LLC", "MLC", "NLC", "OLC", "PLC",
"QLC", "RLC", "SLC", "TLC", "ULC", "VLC", "WLC", "XLC", "YLC", "ZLC",
"AUC", "BUC", "CUC", "DUC", "EUC", "FUC", "GUC", "HUC", "IUC", "JUC",
"KUC", "LUC", "MUC", "NUC", "OUC", "PUC", "QUC", "RUC", "SUC", "TUC",
"UUC", "VUC", "WUC", "XUC", "YUC", "ZUC", "D1", "D2", "D3", "D4", "D5",
"D6", "D7", "D8", "D9", "D0", "OtherChar", "UnderscoreAlphaNumerics",
"AlphaNumerics", "AlphaNumeric", "NonAlphaNumeric", "HexDigit", "ASCII"
]
private static let _LITERAL_NAMES: [String?] = [
nil, nil, nil, "'\\a'", nil, "'\\e'", "'\\f'", "'\\n'", "'\\r'", "'\\t'",
"'\\'", nil, "'.'", "'\\C'", "'\\d'", "'\\D'", "'\\h'", "'\\H'", "'\\N'",
nil, nil, "'\\R'", "'\\s'", "'\\S'", "'\\v'", "'\\V'", "'\\w'", "'\\W'",
"'\\X'", "'['", "']'", "'^'", "'-'", nil, nil, "'?'", "'+'", "'*'", "'{'",
"'}'", "','", "'\\b'", "'\\B'", "'\\A'", "'$'", "'\\Z'", "'\\z'", "'\\G'",
"'\\K'", "'\\g'", "'\\k'", "'|'", "'('", "')'", "'<'", "'>'", "'''", "'_'",
"':'", "'#'", "'='", "'!'", "'&'", "'a'", "'b'", "'c'", "'d'", "'e'",
"'f'", "'g'", "'h'", "'i'", "'j'", "'k'", "'l'", "'m'", "'n'", "'o'",
"'p'", "'q'", "'r'", "'s'", "'t'", "'u'", "'v'", "'w'", "'x'", "'y'",
"'z'", "'A'", "'B'", "'C'", "'D'", "'E'", "'F'", "'G'", "'H'", "'I'",
"'J'", "'K'", "'L'", "'M'", "'N'", "'O'", "'P'", "'Q'", "'R'", "'S'",
"'T'", "'U'", "'V'", "'W'", "'X'", "'Y'", "'Z'", "'1'", "'2'", "'3'",
"'4'", "'5'", "'6'", "'7'", "'8'", "'9'", "'0'"
]
private static let _SYMBOLIC_NAMES: [String?] = [
nil, "Quoted", "BlockQuoted", "BellChar", "ControlChar", "EscapeChar",
"FormFeed", "NewLine", "CarriageReturn", "Tab", "Backslash", "HexChar",
"Dot", "OneDataUnit", "DecimalDigit", "NotDecimalDigit", "HorizontalWhiteSpace",
"NotHorizontalWhiteSpace", "NotNewLine", "CharWithProperty", "CharWithoutProperty",
"NewLineSequence", "WhiteSpace", "NotWhiteSpace", "VerticalWhiteSpace",
"NotVerticalWhiteSpace", "WordChar", "NotWordChar", "ExtendedUnicodeChar",
"CharacterClassStart", "CharacterClassEnd", "Caret", "Hyphen", "POSIXNamedSet",
"POSIXNegatedNamedSet", "QuestionMark", "Plus", "Star", "OpenBrace", "CloseBrace",
"Comma", "WordBoundary", "NonWordBoundary", "StartOfSubject", "EndOfSubjectOrLine",
"EndOfSubjectOrLineEndOfSubject", "EndOfSubject", "PreviousMatchInSubject",
"ResetStartMatch", "SubroutineOrNamedReferenceStartG", "NamedReferenceStartK",
"Pipe", "OpenParen", "CloseParen", "LessThan", "GreaterThan", "SingleQuote",
"Underscore", "Colon", "Hash", "Equals", "Exclamation", "Ampersand", "ALC",
"BLC", "CLC", "DLC", "ELC", "FLC", "GLC", "HLC", "ILC", "JLC", "KLC",
"LLC", "MLC", "NLC", "OLC", "PLC", "QLC", "RLC", "SLC", "TLC", "ULC",
"VLC", "WLC", "XLC", "YLC", "ZLC", "AUC", "BUC", "CUC", "DUC", "EUC",
"FUC", "GUC", "HUC", "IUC", "JUC", "KUC", "LUC", "MUC", "NUC", "OUC",
"PUC", "QUC", "RUC", "SUC", "TUC", "UUC", "VUC", "WUC", "XUC", "YUC",
"ZUC", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D0", "OtherChar"
]
public
static let VOCABULARY = Vocabulary(_LITERAL_NAMES, _SYMBOLIC_NAMES)
override open
func getVocabulary() -> Vocabulary {
return PCRELexer.VOCABULARY
}
public
required init(_ input: CharStream) {
RuntimeMetaData.checkVersion("4.11.1", RuntimeMetaData.VERSION)
super.init(input)
_interp = LexerATNSimulator(self, PCRELexer._ATN, PCRELexer._decisionToDFA, PCRELexer._sharedContextCache)
}
override open
func getGrammarFileName() -> String { return "PCRE.g4" }
override open
func getRuleNames() -> [String] { return PCRELexer.ruleNames }
override open
func getSerializedATN() -> [Int] { return PCRELexer._serializedATN }
override open
func getChannelNames() -> [String] { return PCRELexer.channelNames }
override open
func getModeNames() -> [String] { return PCRELexer.modeNames }
override open
func getATN() -> ATN { return PCRELexer._ATN }
static let _serializedATN:[Int] = [
4,0,125,616,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,
7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21,
7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28,
7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35,
7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42,
7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49,
7,49,2,50,7,50,2,51,7,51,2,52,7,52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,
7,56,2,57,7,57,2,58,7,58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,
7,63,2,64,7,64,2,65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,
7,70,2,71,7,71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,
7,77,2,78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,2,83,7,83,2,84,
7,84,2,85,7,85,2,86,7,86,2,87,7,87,2,88,7,88,2,89,7,89,2,90,7,90,2,91,
7,91,2,92,7,92,2,93,7,93,2,94,7,94,2,95,7,95,2,96,7,96,2,97,7,97,2,98,
7,98,2,99,7,99,2,100,7,100,2,101,7,101,2,102,7,102,2,103,7,103,2,104,7,
104,2,105,7,105,2,106,7,106,2,107,7,107,2,108,7,108,2,109,7,109,2,110,
7,110,2,111,7,111,2,112,7,112,2,113,7,113,2,114,7,114,2,115,7,115,2,116,
7,116,2,117,7,117,2,118,7,118,2,119,7,119,2,120,7,120,2,121,7,121,2,122,
7,122,2,123,7,123,2,124,7,124,2,125,7,125,2,126,7,126,2,127,7,127,2,128,
7,128,2,129,7,129,2,130,7,130,1,0,1,0,1,0,1,1,1,1,1,1,1,1,5,1,271,8,1,
10,1,12,1,274,9,1,1,1,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,4,1,4,
1,4,1,5,1,5,1,5,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,9,1,9,1,10,1,10,
1,10,1,10,1,10,1,10,1,10,1,10,1,10,1,10,4,10,314,8,10,11,10,12,10,315,
1,10,1,10,3,10,320,8,10,1,11,1,11,1,12,1,12,1,12,1,13,1,13,1,13,1,14,1,
14,1,14,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,
18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,
21,1,21,1,21,1,22,1,22,1,22,1,23,1,23,1,23,1,24,1,24,1,24,1,25,1,25,1,
25,1,26,1,26,1,26,1,27,1,27,1,27,1,28,1,28,1,29,1,29,1,30,1,30,1,31,1,
31,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,
33,1,33,1,33,1,33,1,33,1,33,1,34,1,34,1,35,1,35,1,36,1,36,1,37,1,37,1,
38,1,38,1,39,1,39,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42,1,42,1,43,1,
43,1,44,1,44,1,44,1,45,1,45,1,45,1,46,1,46,1,46,1,47,1,47,1,47,1,48,1,
48,1,48,1,49,1,49,1,49,1,50,1,50,1,51,1,51,1,52,1,52,1,53,1,53,1,54,1,
54,1,55,1,55,1,56,1,56,1,57,1,57,1,58,1,58,1,59,1,59,1,60,1,60,1,61,1,
61,1,62,1,62,1,63,1,63,1,64,1,64,1,65,1,65,1,66,1,66,1,67,1,67,1,68,1,
68,1,69,1,69,1,70,1,70,1,71,1,71,1,72,1,72,1,73,1,73,1,74,1,74,1,75,1,
75,1,76,1,76,1,77,1,77,1,78,1,78,1,79,1,79,1,80,1,80,1,81,1,81,1,82,1,
82,1,83,1,83,1,84,1,84,1,85,1,85,1,86,1,86,1,87,1,87,1,88,1,88,1,89,1,
89,1,90,1,90,1,91,1,91,1,92,1,92,1,93,1,93,1,94,1,94,1,95,1,95,1,96,1,
96,1,97,1,97,1,98,1,98,1,99,1,99,1,100,1,100,1,101,1,101,1,102,1,102,1,
103,1,103,1,104,1,104,1,105,1,105,1,106,1,106,1,107,1,107,1,108,1,108,
1,109,1,109,1,110,1,110,1,111,1,111,1,112,1,112,1,113,1,113,1,114,1,114,
1,115,1,115,1,116,1,116,1,117,1,117,1,118,1,118,1,119,1,119,1,120,1,120,
1,121,1,121,1,122,1,122,1,123,1,123,1,124,1,124,1,125,1,125,4,125,600,
8,125,11,125,12,125,601,1,126,4,126,605,8,126,11,126,12,126,606,1,127,
1,127,1,128,1,128,1,129,1,129,1,130,1,130,1,272,0,131,1,1,3,2,5,3,7,4,
9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,
35,18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,
59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,
83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,49,99,50,101,51,103,52,105,
53,107,54,109,55,111,56,113,57,115,58,117,59,119,60,121,61,123,62,125,
63,127,64,129,65,131,66,133,67,135,68,137,69,139,70,141,71,143,72,145,
73,147,74,149,75,151,76,153,77,155,78,157,79,159,80,161,81,163,82,165,
83,167,84,169,85,171,86,173,87,175,88,177,89,179,90,181,91,183,92,185,
93,187,94,189,95,191,96,193,97,195,98,197,99,199,100,201,101,203,102,205,
103,207,104,209,105,211,106,213,107,215,108,217,109,219,110,221,111,223,
112,225,113,227,114,229,115,231,116,233,117,235,118,237,119,239,120,241,
121,243,122,245,123,247,124,249,125,251,0,253,0,255,0,257,0,259,0,261,
0,1,0,3,3,0,48,57,65,90,97,122,3,0,48,57,65,70,97,102,1,0,0,127,615,0,
1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,
0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0,0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,
1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,
0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0,0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,
1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51,1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,
0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0,0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,
1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73,1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,
0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0,0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,
1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,95,1,0,0,0,0,97,1,0,0,0,0,99,1,0,0,
0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1,0,0,0,0,109,1,0,0,
0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0,117,1,0,0,0,0,119,1,0,0,
0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0,0,0,0,127,1,0,0,0,0,129,1,0,0,
0,0,131,1,0,0,0,0,133,1,0,0,0,0,135,1,0,0,0,0,137,1,0,0,0,0,139,1,0,0,
0,0,141,1,0,0,0,0,143,1,0,0,0,0,145,1,0,0,0,0,147,1,0,0,0,0,149,1,0,0,
0,0,151,1,0,0,0,0,153,1,0,0,0,0,155,1,0,0,0,0,157,1,0,0,0,0,159,1,0,0,
0,0,161,1,0,0,0,0,163,1,0,0,0,0,165,1,0,0,0,0,167,1,0,0,0,0,169,1,0,0,
0,0,171,1,0,0,0,0,173,1,0,0,0,0,175,1,0,0,0,0,177,1,0,0,0,0,179,1,0,0,
0,0,181,1,0,0,0,0,183,1,0,0,0,0,185,1,0,0,0,0,187,1,0,0,0,0,189,1,0,0,
0,0,191,1,0,0,0,0,193,1,0,0,0,0,195,1,0,0,0,0,197,1,0,0,0,0,199,1,0,0,
0,0,201,1,0,0,0,0,203,1,0,0,0,0,205,1,0,0,0,0,207,1,0,0,0,0,209,1,0,0,
0,0,211,1,0,0,0,0,213,1,0,0,0,0,215,1,0,0,0,0,217,1,0,0,0,0,219,1,0,0,
0,0,221,1,0,0,0,0,223,1,0,0,0,0,225,1,0,0,0,0,227,1,0,0,0,0,229,1,0,0,
0,0,231,1,0,0,0,0,233,1,0,0,0,0,235,1,0,0,0,0,237,1,0,0,0,0,239,1,0,0,
0,0,241,1,0,0,0,0,243,1,0,0,0,0,245,1,0,0,0,0,247,1,0,0,0,0,249,1,0,0,
0,1,263,1,0,0,0,3,266,1,0,0,0,5,278,1,0,0,0,7,281,1,0,0,0,9,286,1,0,0,
0,11,289,1,0,0,0,13,292,1,0,0,0,15,295,1,0,0,0,17,298,1,0,0,0,19,301,1,
0,0,0,21,303,1,0,0,0,23,321,1,0,0,0,25,323,1,0,0,0,27,326,1,0,0,0,29,329,
1,0,0,0,31,332,1,0,0,0,33,335,1,0,0,0,35,338,1,0,0,0,37,341,1,0,0,0,39,
348,1,0,0,0,41,355,1,0,0,0,43,358,1,0,0,0,45,361,1,0,0,0,47,364,1,0,0,
0,49,367,1,0,0,0,51,370,1,0,0,0,53,373,1,0,0,0,55,376,1,0,0,0,57,379,1,
0,0,0,59,381,1,0,0,0,61,383,1,0,0,0,63,385,1,0,0,0,65,387,1,0,0,0,67,396,
1,0,0,0,69,406,1,0,0,0,71,408,1,0,0,0,73,410,1,0,0,0,75,412,1,0,0,0,77,
414,1,0,0,0,79,416,1,0,0,0,81,418,1,0,0,0,83,421,1,0,0,0,85,424,1,0,0,
0,87,427,1,0,0,0,89,429,1,0,0,0,91,432,1,0,0,0,93,435,1,0,0,0,95,438,1,
0,0,0,97,441,1,0,0,0,99,444,1,0,0,0,101,447,1,0,0,0,103,449,1,0,0,0,105,
451,1,0,0,0,107,453,1,0,0,0,109,455,1,0,0,0,111,457,1,0,0,0,113,459,1,
0,0,0,115,461,1,0,0,0,117,463,1,0,0,0,119,465,1,0,0,0,121,467,1,0,0,0,
123,469,1,0,0,0,125,471,1,0,0,0,127,473,1,0,0,0,129,475,1,0,0,0,131,477,
1,0,0,0,133,479,1,0,0,0,135,481,1,0,0,0,137,483,1,0,0,0,139,485,1,0,0,
0,141,487,1,0,0,0,143,489,1,0,0,0,145,491,1,0,0,0,147,493,1,0,0,0,149,
495,1,0,0,0,151,497,1,0,0,0,153,499,1,0,0,0,155,501,1,0,0,0,157,503,1,
0,0,0,159,505,1,0,0,0,161,507,1,0,0,0,163,509,1,0,0,0,165,511,1,0,0,0,
167,513,1,0,0,0,169,515,1,0,0,0,171,517,1,0,0,0,173,519,1,0,0,0,175,521,
1,0,0,0,177,523,1,0,0,0,179,525,1,0,0,0,181,527,1,0,0,0,183,529,1,0,0,
0,185,531,1,0,0,0,187,533,1,0,0,0,189,535,1,0,0,0,191,537,1,0,0,0,193,
539,1,0,0,0,195,541,1,0,0,0,197,543,1,0,0,0,199,545,1,0,0,0,201,547,1,
0,0,0,203,549,1,0,0,0,205,551,1,0,0,0,207,553,1,0,0,0,209,555,1,0,0,0,
211,557,1,0,0,0,213,559,1,0,0,0,215,561,1,0,0,0,217,563,1,0,0,0,219,565,
1,0,0,0,221,567,1,0,0,0,223,569,1,0,0,0,225,571,1,0,0,0,227,573,1,0,0,
0,229,575,1,0,0,0,231,577,1,0,0,0,233,579,1,0,0,0,235,581,1,0,0,0,237,
583,1,0,0,0,239,585,1,0,0,0,241,587,1,0,0,0,243,589,1,0,0,0,245,591,1,
0,0,0,247,593,1,0,0,0,249,595,1,0,0,0,251,599,1,0,0,0,253,604,1,0,0,0,
255,608,1,0,0,0,257,610,1,0,0,0,259,612,1,0,0,0,261,614,1,0,0,0,263,264,
5,92,0,0,264,265,3,257,128,0,265,2,1,0,0,0,266,267,5,92,0,0,267,268,5,
81,0,0,268,272,1,0,0,0,269,271,9,0,0,0,270,269,1,0,0,0,271,274,1,0,0,0,
272,273,1,0,0,0,272,270,1,0,0,0,273,275,1,0,0,0,274,272,1,0,0,0,275,276,
5,92,0,0,276,277,5,69,0,0,277,4,1,0,0,0,278,279,5,92,0,0,279,280,5,97,
0,0,280,6,1,0,0,0,281,282,5,92,0,0,282,283,5,99,0,0,283,284,1,0,0,0,284,
285,3,261,130,0,285,8,1,0,0,0,286,287,5,92,0,0,287,288,5,101,0,0,288,10,
1,0,0,0,289,290,5,92,0,0,290,291,5,102,0,0,291,12,1,0,0,0,292,293,5,92,
0,0,293,294,5,110,0,0,294,14,1,0,0,0,295,296,5,92,0,0,296,297,5,114,0,
0,297,16,1,0,0,0,298,299,5,92,0,0,299,300,5,116,0,0,300,18,1,0,0,0,301,
302,5,92,0,0,302,20,1,0,0,0,303,304,5,92,0,0,304,305,5,120,0,0,305,319,
1,0,0,0,306,307,3,259,129,0,307,308,3,259,129,0,308,320,1,0,0,0,309,310,
5,123,0,0,310,311,3,259,129,0,311,313,3,259,129,0,312,314,3,259,129,0,
313,312,1,0,0,0,314,315,1,0,0,0,315,313,1,0,0,0,315,316,1,0,0,0,316,317,
1,0,0,0,317,318,5,125,0,0,318,320,1,0,0,0,319,306,1,0,0,0,319,309,1,0,
0,0,320,22,1,0,0,0,321,322,5,46,0,0,322,24,1,0,0,0,323,324,5,92,0,0,324,
325,5,67,0,0,325,26,1,0,0,0,326,327,5,92,0,0,327,328,5,100,0,0,328,28,
1,0,0,0,329,330,5,92,0,0,330,331,5,68,0,0,331,30,1,0,0,0,332,333,5,92,
0,0,333,334,5,104,0,0,334,32,1,0,0,0,335,336,5,92,0,0,336,337,5,72,0,0,
337,34,1,0,0,0,338,339,5,92,0,0,339,340,5,78,0,0,340,36,1,0,0,0,341,342,
5,92,0,0,342,343,5,112,0,0,343,344,5,123,0,0,344,345,1,0,0,0,345,346,3,
251,125,0,346,347,5,125,0,0,347,38,1,0,0,0,348,349,5,92,0,0,349,350,5,
80,0,0,350,351,5,123,0,0,351,352,1,0,0,0,352,353,3,251,125,0,353,354,5,
125,0,0,354,40,1,0,0,0,355,356,5,92,0,0,356,357,5,82,0,0,357,42,1,0,0,
0,358,359,5,92,0,0,359,360,5,115,0,0,360,44,1,0,0,0,361,362,5,92,0,0,362,
363,5,83,0,0,363,46,1,0,0,0,364,365,5,92,0,0,365,366,5,118,0,0,366,48,
1,0,0,0,367,368,5,92,0,0,368,369,5,86,0,0,369,50,1,0,0,0,370,371,5,92,
0,0,371,372,5,119,0,0,372,52,1,0,0,0,373,374,5,92,0,0,374,375,5,87,0,0,
375,54,1,0,0,0,376,377,5,92,0,0,377,378,5,88,0,0,378,56,1,0,0,0,379,380,
5,91,0,0,380,58,1,0,0,0,381,382,5,93,0,0,382,60,1,0,0,0,383,384,5,94,0,
0,384,62,1,0,0,0,385,386,5,45,0,0,386,64,1,0,0,0,387,388,5,91,0,0,388,
389,5,91,0,0,389,390,5,58,0,0,390,391,1,0,0,0,391,392,3,253,126,0,392,
393,5,58,0,0,393,394,5,93,0,0,394,395,5,93,0,0,395,66,1,0,0,0,396,397,
5,91,0,0,397,398,5,91,0,0,398,399,5,58,0,0,399,400,5,94,0,0,400,401,1,
0,0,0,401,402,3,253,126,0,402,403,5,58,0,0,403,404,5,93,0,0,404,405,5,
93,0,0,405,68,1,0,0,0,406,407,5,63,0,0,407,70,1,0,0,0,408,409,5,43,0,0,
409,72,1,0,0,0,410,411,5,42,0,0,411,74,1,0,0,0,412,413,5,123,0,0,413,76,
1,0,0,0,414,415,5,125,0,0,415,78,1,0,0,0,416,417,5,44,0,0,417,80,1,0,0,
0,418,419,5,92,0,0,419,420,5,98,0,0,420,82,1,0,0,0,421,422,5,92,0,0,422,
423,5,66,0,0,423,84,1,0,0,0,424,425,5,92,0,0,425,426,5,65,0,0,426,86,1,
0,0,0,427,428,5,36,0,0,428,88,1,0,0,0,429,430,5,92,0,0,430,431,5,90,0,
0,431,90,1,0,0,0,432,433,5,92,0,0,433,434,5,122,0,0,434,92,1,0,0,0,435,
436,5,92,0,0,436,437,5,71,0,0,437,94,1,0,0,0,438,439,5,92,0,0,439,440,
5,75,0,0,440,96,1,0,0,0,441,442,5,92,0,0,442,443,5,103,0,0,443,98,1,0,
0,0,444,445,5,92,0,0,445,446,5,107,0,0,446,100,1,0,0,0,447,448,5,124,0,
0,448,102,1,0,0,0,449,450,5,40,0,0,450,104,1,0,0,0,451,452,5,41,0,0,452,
106,1,0,0,0,453,454,5,60,0,0,454,108,1,0,0,0,455,456,5,62,0,0,456,110,
1,0,0,0,457,458,5,39,0,0,458,112,1,0,0,0,459,460,5,95,0,0,460,114,1,0,
0,0,461,462,5,58,0,0,462,116,1,0,0,0,463,464,5,35,0,0,464,118,1,0,0,0,
465,466,5,61,0,0,466,120,1,0,0,0,467,468,5,33,0,0,468,122,1,0,0,0,469,
470,5,38,0,0,470,124,1,0,0,0,471,472,5,97,0,0,472,126,1,0,0,0,473,474,
5,98,0,0,474,128,1,0,0,0,475,476,5,99,0,0,476,130,1,0,0,0,477,478,5,100,
0,0,478,132,1,0,0,0,479,480,5,101,0,0,480,134,1,0,0,0,481,482,5,102,0,
0,482,136,1,0,0,0,483,484,5,103,0,0,484,138,1,0,0,0,485,486,5,104,0,0,
486,140,1,0,0,0,487,488,5,105,0,0,488,142,1,0,0,0,489,490,5,106,0,0,490,
144,1,0,0,0,491,492,5,107,0,0,492,146,1,0,0,0,493,494,5,108,0,0,494,148,
1,0,0,0,495,496,5,109,0,0,496,150,1,0,0,0,497,498,5,110,0,0,498,152,1,
0,0,0,499,500,5,111,0,0,500,154,1,0,0,0,501,502,5,112,0,0,502,156,1,0,
0,0,503,504,5,113,0,0,504,158,1,0,0,0,505,506,5,114,0,0,506,160,1,0,0,
0,507,508,5,115,0,0,508,162,1,0,0,0,509,510,5,116,0,0,510,164,1,0,0,0,
511,512,5,117,0,0,512,166,1,0,0,0,513,514,5,118,0,0,514,168,1,0,0,0,515,
516,5,119,0,0,516,170,1,0,0,0,517,518,5,120,0,0,518,172,1,0,0,0,519,520,
5,121,0,0,520,174,1,0,0,0,521,522,5,122,0,0,522,176,1,0,0,0,523,524,5,
65,0,0,524,178,1,0,0,0,525,526,5,66,0,0,526,180,1,0,0,0,527,528,5,67,0,
0,528,182,1,0,0,0,529,530,5,68,0,0,530,184,1,0,0,0,531,532,5,69,0,0,532,
186,1,0,0,0,533,534,5,70,0,0,534,188,1,0,0,0,535,536,5,71,0,0,536,190,
1,0,0,0,537,538,5,72,0,0,538,192,1,0,0,0,539,540,5,73,0,0,540,194,1,0,
0,0,541,542,5,74,0,0,542,196,1,0,0,0,543,544,5,75,0,0,544,198,1,0,0,0,
545,546,5,76,0,0,546,200,1,0,0,0,547,548,5,77,0,0,548,202,1,0,0,0,549,
550,5,78,0,0,550,204,1,0,0,0,551,552,5,79,0,0,552,206,1,0,0,0,553,554,
5,80,0,0,554,208,1,0,0,0,555,556,5,81,0,0,556,210,1,0,0,0,557,558,5,82,
0,0,558,212,1,0,0,0,559,560,5,83,0,0,560,214,1,0,0,0,561,562,5,84,0,0,
562,216,1,0,0,0,563,564,5,85,0,0,564,218,1,0,0,0,565,566,5,86,0,0,566,
220,1,0,0,0,567,568,5,87,0,0,568,222,1,0,0,0,569,570,5,88,0,0,570,224,
1,0,0,0,571,572,5,89,0,0,572,226,1,0,0,0,573,574,5,90,0,0,574,228,1,0,
0,0,575,576,5,49,0,0,576,230,1,0,0,0,577,578,5,50,0,0,578,232,1,0,0,0,
579,580,5,51,0,0,580,234,1,0,0,0,581,582,5,52,0,0,582,236,1,0,0,0,583,
584,5,53,0,0,584,238,1,0,0,0,585,586,5,54,0,0,586,240,1,0,0,0,587,588,
5,55,0,0,588,242,1,0,0,0,589,590,5,56,0,0,590,244,1,0,0,0,591,592,5,57,
0,0,592,246,1,0,0,0,593,594,5,48,0,0,594,248,1,0,0,0,595,596,9,0,0,0,596,
250,1,0,0,0,597,600,5,95,0,0,598,600,3,255,127,0,599,597,1,0,0,0,599,598,
1,0,0,0,600,601,1,0,0,0,601,599,1,0,0,0,601,602,1,0,0,0,602,252,1,0,0,
0,603,605,3,255,127,0,604,603,1,0,0,0,605,606,1,0,0,0,606,604,1,0,0,0,
606,607,1,0,0,0,607,254,1,0,0,0,608,609,7,0,0,0,609,256,1,0,0,0,610,611,
8,0,0,0,611,258,1,0,0,0,612,613,7,1,0,0,613,260,1,0,0,0,614,615,7,2,0,
0,615,262,1,0,0,0,7,0,272,315,319,599,601,606,0
]
public
static let _ATN: ATN = try! ATNDeserializer().deserialize(_serializedATN)
}

View File

@ -0,0 +1,241 @@
Quoted=1
BlockQuoted=2
BellChar=3
ControlChar=4
EscapeChar=5
FormFeed=6
NewLine=7
CarriageReturn=8
Tab=9
Backslash=10
HexChar=11
Dot=12
OneDataUnit=13
DecimalDigit=14
NotDecimalDigit=15
HorizontalWhiteSpace=16
NotHorizontalWhiteSpace=17
NotNewLine=18
CharWithProperty=19
CharWithoutProperty=20
NewLineSequence=21
WhiteSpace=22
NotWhiteSpace=23
VerticalWhiteSpace=24
NotVerticalWhiteSpace=25
WordChar=26
NotWordChar=27
ExtendedUnicodeChar=28
CharacterClassStart=29
CharacterClassEnd=30
Caret=31
Hyphen=32
POSIXNamedSet=33
POSIXNegatedNamedSet=34
QuestionMark=35
Plus=36
Star=37
OpenBrace=38
CloseBrace=39
Comma=40
WordBoundary=41
NonWordBoundary=42
StartOfSubject=43
EndOfSubjectOrLine=44
EndOfSubjectOrLineEndOfSubject=45
EndOfSubject=46
PreviousMatchInSubject=47
ResetStartMatch=48
SubroutineOrNamedReferenceStartG=49
NamedReferenceStartK=50
Pipe=51
OpenParen=52
CloseParen=53
LessThan=54
GreaterThan=55
SingleQuote=56
Underscore=57
Colon=58
Hash=59
Equals=60
Exclamation=61
Ampersand=62
ALC=63
BLC=64
CLC=65
DLC=66
ELC=67
FLC=68
GLC=69
HLC=70
ILC=71
JLC=72
KLC=73
LLC=74
MLC=75
NLC=76
OLC=77
PLC=78
QLC=79
RLC=80
SLC=81
TLC=82
ULC=83
VLC=84
WLC=85
XLC=86
YLC=87
ZLC=88
AUC=89
BUC=90
CUC=91
DUC=92
EUC=93
FUC=94
GUC=95
HUC=96
IUC=97
JUC=98
KUC=99
LUC=100
MUC=101
NUC=102
OUC=103
PUC=104
QUC=105
RUC=106
SUC=107
TUC=108
UUC=109
VUC=110
WUC=111
XUC=112
YUC=113
ZUC=114
D1=115
D2=116
D3=117
D4=118
D5=119
D6=120
D7=121
D8=122
D9=123
D0=124
OtherChar=125
'\\a'=3
'\\e'=5
'\\f'=6
'\\n'=7
'\\r'=8
'\\t'=9
'\\'=10
'.'=12
'\\C'=13
'\\d'=14
'\\D'=15
'\\h'=16
'\\H'=17
'\\N'=18
'\\R'=21
'\\s'=22
'\\S'=23
'\\v'=24
'\\V'=25
'\\w'=26
'\\W'=27
'\\X'=28
'['=29
']'=30
'^'=31
'-'=32
'?'=35
'+'=36
'*'=37
'{'=38
'}'=39
','=40
'\\b'=41
'\\B'=42
'\\A'=43
'$'=44
'\\Z'=45
'\\z'=46
'\\G'=47
'\\K'=48
'\\g'=49
'\\k'=50
'|'=51
'('=52
')'=53
'<'=54
'>'=55
'\''=56
'_'=57
':'=58
'#'=59
'='=60
'!'=61
'&'=62
'a'=63
'b'=64
'c'=65
'd'=66
'e'=67
'f'=68
'g'=69
'h'=70
'i'=71
'j'=72
'k'=73
'l'=74
'm'=75
'n'=76
'o'=77
'p'=78
'q'=79
'r'=80
's'=81
't'=82
'u'=83
'v'=84
'w'=85
'x'=86
'y'=87
'z'=88
'A'=89
'B'=90
'C'=91
'D'=92
'E'=93
'F'=94
'G'=95
'H'=96
'I'=97
'J'=98
'K'=99
'L'=100
'M'=101
'N'=102
'O'=103
'P'=104
'Q'=105
'R'=106
'S'=107
'T'=108
'U'=109
'V'=110
'W'=111
'X'=112
'Y'=113
'Z'=114
'1'=115
'2'=116
'3'=117
'4'=118
'5'=119
'6'=120
'7'=121
'8'=122
'9'=123
'0'=124

View File

@ -0,0 +1,453 @@
// Generated from java-escape by ANTLR 4.11.1
import Antlr4
/**
* This interface defines a complete listener for a parse tree produced by
* {@link PCREParser}.
*/
public protocol PCREListener: ParseTreeListener {
/**
* Enter a parse tree produced by {@link PCREParser#parse}.
- Parameters:
- ctx: the parse tree
*/
func enterParse(_ ctx: PCREParser.ParseContext)
/**
* Exit a parse tree produced by {@link PCREParser#parse}.
- Parameters:
- ctx: the parse tree
*/
func exitParse(_ ctx: PCREParser.ParseContext)
/**
* Enter a parse tree produced by {@link PCREParser#alternation}.
- Parameters:
- ctx: the parse tree
*/
func enterAlternation(_ ctx: PCREParser.AlternationContext)
/**
* Exit a parse tree produced by {@link PCREParser#alternation}.
- Parameters:
- ctx: the parse tree
*/
func exitAlternation(_ ctx: PCREParser.AlternationContext)
/**
* Enter a parse tree produced by {@link PCREParser#expr}.
- Parameters:
- ctx: the parse tree
*/
func enterExpr(_ ctx: PCREParser.ExprContext)
/**
* Exit a parse tree produced by {@link PCREParser#expr}.
- Parameters:
- ctx: the parse tree
*/
func exitExpr(_ ctx: PCREParser.ExprContext)
/**
* Enter a parse tree produced by {@link PCREParser#element}.
- Parameters:
- ctx: the parse tree
*/
func enterElement(_ ctx: PCREParser.ElementContext)
/**
* Exit a parse tree produced by {@link PCREParser#element}.
- Parameters:
- ctx: the parse tree
*/
func exitElement(_ ctx: PCREParser.ElementContext)
/**
* Enter a parse tree produced by {@link PCREParser#quantifier}.
- Parameters:
- ctx: the parse tree
*/
func enterQuantifier(_ ctx: PCREParser.QuantifierContext)
/**
* Exit a parse tree produced by {@link PCREParser#quantifier}.
- Parameters:
- ctx: the parse tree
*/
func exitQuantifier(_ ctx: PCREParser.QuantifierContext)
/**
* Enter a parse tree produced by {@link PCREParser#quantifier_type}.
- Parameters:
- ctx: the parse tree
*/
func enterQuantifier_type(_ ctx: PCREParser.Quantifier_typeContext)
/**
* Exit a parse tree produced by {@link PCREParser#quantifier_type}.
- Parameters:
- ctx: the parse tree
*/
func exitQuantifier_type(_ ctx: PCREParser.Quantifier_typeContext)
/**
* Enter a parse tree produced by {@link PCREParser#character_class}.
- Parameters:
- ctx: the parse tree
*/
func enterCharacter_class(_ ctx: PCREParser.Character_classContext)
/**
* Exit a parse tree produced by {@link PCREParser#character_class}.
- Parameters:
- ctx: the parse tree
*/
func exitCharacter_class(_ ctx: PCREParser.Character_classContext)
/**
* Enter a parse tree produced by {@link PCREParser#backreference}.
- Parameters:
- ctx: the parse tree
*/
func enterBackreference(_ ctx: PCREParser.BackreferenceContext)
/**
* Exit a parse tree produced by {@link PCREParser#backreference}.
- Parameters:
- ctx: the parse tree
*/
func exitBackreference(_ ctx: PCREParser.BackreferenceContext)
/**
* Enter a parse tree produced by {@link PCREParser#backreference_or_octal}.
- Parameters:
- ctx: the parse tree
*/
func enterBackreference_or_octal(_ ctx: PCREParser.Backreference_or_octalContext)
/**
* Exit a parse tree produced by {@link PCREParser#backreference_or_octal}.
- Parameters:
- ctx: the parse tree
*/
func exitBackreference_or_octal(_ ctx: PCREParser.Backreference_or_octalContext)
/**
* Enter a parse tree produced by {@link PCREParser#capture}.
- Parameters:
- ctx: the parse tree
*/
func enterCapture(_ ctx: PCREParser.CaptureContext)
/**
* Exit a parse tree produced by {@link PCREParser#capture}.
- Parameters:
- ctx: the parse tree
*/
func exitCapture(_ ctx: PCREParser.CaptureContext)
/**
* Enter a parse tree produced by {@link PCREParser#non_capture}.
- Parameters:
- ctx: the parse tree
*/
func enterNon_capture(_ ctx: PCREParser.Non_captureContext)
/**
* Exit a parse tree produced by {@link PCREParser#non_capture}.
- Parameters:
- ctx: the parse tree
*/
func exitNon_capture(_ ctx: PCREParser.Non_captureContext)
/**
* Enter a parse tree produced by {@link PCREParser#comment}.
- Parameters:
- ctx: the parse tree
*/
func enterComment(_ ctx: PCREParser.CommentContext)
/**
* Exit a parse tree produced by {@link PCREParser#comment}.
- Parameters:
- ctx: the parse tree
*/
func exitComment(_ ctx: PCREParser.CommentContext)
/**
* Enter a parse tree produced by {@link PCREParser#option}.
- Parameters:
- ctx: the parse tree
*/
func enterOption(_ ctx: PCREParser.OptionContext)
/**
* Exit a parse tree produced by {@link PCREParser#option}.
- Parameters:
- ctx: the parse tree
*/
func exitOption(_ ctx: PCREParser.OptionContext)
/**
* Enter a parse tree produced by {@link PCREParser#option_flags}.
- Parameters:
- ctx: the parse tree
*/
func enterOption_flags(_ ctx: PCREParser.Option_flagsContext)
/**
* Exit a parse tree produced by {@link PCREParser#option_flags}.
- Parameters:
- ctx: the parse tree
*/
func exitOption_flags(_ ctx: PCREParser.Option_flagsContext)
/**
* Enter a parse tree produced by {@link PCREParser#option_flag}.
- Parameters:
- ctx: the parse tree
*/
func enterOption_flag(_ ctx: PCREParser.Option_flagContext)
/**
* Exit a parse tree produced by {@link PCREParser#option_flag}.
- Parameters:
- ctx: the parse tree
*/
func exitOption_flag(_ ctx: PCREParser.Option_flagContext)
/**
* Enter a parse tree produced by {@link PCREParser#look_around}.
- Parameters:
- ctx: the parse tree
*/
func enterLook_around(_ ctx: PCREParser.Look_aroundContext)
/**
* Exit a parse tree produced by {@link PCREParser#look_around}.
- Parameters:
- ctx: the parse tree
*/
func exitLook_around(_ ctx: PCREParser.Look_aroundContext)
/**
* Enter a parse tree produced by {@link PCREParser#subroutine_reference}.
- Parameters:
- ctx: the parse tree
*/
func enterSubroutine_reference(_ ctx: PCREParser.Subroutine_referenceContext)
/**
* Exit a parse tree produced by {@link PCREParser#subroutine_reference}.
- Parameters:
- ctx: the parse tree
*/
func exitSubroutine_reference(_ ctx: PCREParser.Subroutine_referenceContext)
/**
* Enter a parse tree produced by {@link PCREParser#conditional}.
- Parameters:
- ctx: the parse tree
*/
func enterConditional(_ ctx: PCREParser.ConditionalContext)
/**
* Exit a parse tree produced by {@link PCREParser#conditional}.
- Parameters:
- ctx: the parse tree
*/
func exitConditional(_ ctx: PCREParser.ConditionalContext)
/**
* Enter a parse tree produced by {@link PCREParser#backtrack_control}.
- Parameters:
- ctx: the parse tree
*/
func enterBacktrack_control(_ ctx: PCREParser.Backtrack_controlContext)
/**
* Exit a parse tree produced by {@link PCREParser#backtrack_control}.
- Parameters:
- ctx: the parse tree
*/
func exitBacktrack_control(_ ctx: PCREParser.Backtrack_controlContext)
/**
* Enter a parse tree produced by {@link PCREParser#newline_convention}.
- Parameters:
- ctx: the parse tree
*/
func enterNewline_convention(_ ctx: PCREParser.Newline_conventionContext)
/**
* Exit a parse tree produced by {@link PCREParser#newline_convention}.
- Parameters:
- ctx: the parse tree
*/
func exitNewline_convention(_ ctx: PCREParser.Newline_conventionContext)
/**
* Enter a parse tree produced by {@link PCREParser#callout}.
- Parameters:
- ctx: the parse tree
*/
func enterCallout(_ ctx: PCREParser.CalloutContext)
/**
* Exit a parse tree produced by {@link PCREParser#callout}.
- Parameters:
- ctx: the parse tree
*/
func exitCallout(_ ctx: PCREParser.CalloutContext)
/**
* Enter a parse tree produced by {@link PCREParser#atom}.
- Parameters:
- ctx: the parse tree
*/
func enterAtom(_ ctx: PCREParser.AtomContext)
/**
* Exit a parse tree produced by {@link PCREParser#atom}.
- Parameters:
- ctx: the parse tree
*/
func exitAtom(_ ctx: PCREParser.AtomContext)
/**
* Enter a parse tree produced by {@link PCREParser#cc_atom}.
- Parameters:
- ctx: the parse tree
*/
func enterCc_atom(_ ctx: PCREParser.Cc_atomContext)
/**
* Exit a parse tree produced by {@link PCREParser#cc_atom}.
- Parameters:
- ctx: the parse tree
*/
func exitCc_atom(_ ctx: PCREParser.Cc_atomContext)
/**
* Enter a parse tree produced by {@link PCREParser#shared_atom}.
- Parameters:
- ctx: the parse tree
*/
func enterShared_atom(_ ctx: PCREParser.Shared_atomContext)
/**
* Exit a parse tree produced by {@link PCREParser#shared_atom}.
- Parameters:
- ctx: the parse tree
*/
func exitShared_atom(_ ctx: PCREParser.Shared_atomContext)
/**
* Enter a parse tree produced by {@link PCREParser#literal}.
- Parameters:
- ctx: the parse tree
*/
func enterLiteral(_ ctx: PCREParser.LiteralContext)
/**
* Exit a parse tree produced by {@link PCREParser#literal}.
- Parameters:
- ctx: the parse tree
*/
func exitLiteral(_ ctx: PCREParser.LiteralContext)
/**
* Enter a parse tree produced by {@link PCREParser#cc_literal}.
- Parameters:
- ctx: the parse tree
*/
func enterCc_literal(_ ctx: PCREParser.Cc_literalContext)
/**
* Exit a parse tree produced by {@link PCREParser#cc_literal}.
- Parameters:
- ctx: the parse tree
*/
func exitCc_literal(_ ctx: PCREParser.Cc_literalContext)
/**
* Enter a parse tree produced by {@link PCREParser#shared_literal}.
- Parameters:
- ctx: the parse tree
*/
func enterShared_literal(_ ctx: PCREParser.Shared_literalContext)
/**
* Exit a parse tree produced by {@link PCREParser#shared_literal}.
- Parameters:
- ctx: the parse tree
*/
func exitShared_literal(_ ctx: PCREParser.Shared_literalContext)
/**
* Enter a parse tree produced by {@link PCREParser#number}.
- Parameters:
- ctx: the parse tree
*/
func enterNumber(_ ctx: PCREParser.NumberContext)
/**
* Exit a parse tree produced by {@link PCREParser#number}.
- Parameters:
- ctx: the parse tree
*/
func exitNumber(_ ctx: PCREParser.NumberContext)
/**
* Enter a parse tree produced by {@link PCREParser#octal_char}.
- Parameters:
- ctx: the parse tree
*/
func enterOctal_char(_ ctx: PCREParser.Octal_charContext)
/**
* Exit a parse tree produced by {@link PCREParser#octal_char}.
- Parameters:
- ctx: the parse tree
*/
func exitOctal_char(_ ctx: PCREParser.Octal_charContext)
/**
* Enter a parse tree produced by {@link PCREParser#octal_digit}.
- Parameters:
- ctx: the parse tree
*/
func enterOctal_digit(_ ctx: PCREParser.Octal_digitContext)
/**
* Exit a parse tree produced by {@link PCREParser#octal_digit}.
- Parameters:
- ctx: the parse tree
*/
func exitOctal_digit(_ ctx: PCREParser.Octal_digitContext)
/**
* Enter a parse tree produced by {@link PCREParser#digits}.
- Parameters:
- ctx: the parse tree
*/
func enterDigits(_ ctx: PCREParser.DigitsContext)
/**
* Exit a parse tree produced by {@link PCREParser#digits}.
- Parameters:
- ctx: the parse tree
*/
func exitDigits(_ ctx: PCREParser.DigitsContext)
/**
* Enter a parse tree produced by {@link PCREParser#digit}.
- Parameters:
- ctx: the parse tree
*/
func enterDigit(_ ctx: PCREParser.DigitContext)
/**
* Exit a parse tree produced by {@link PCREParser#digit}.
- Parameters:
- ctx: the parse tree
*/
func exitDigit(_ ctx: PCREParser.DigitContext)
/**
* Enter a parse tree produced by {@link PCREParser#name}.
- Parameters:
- ctx: the parse tree
*/
func enterName(_ ctx: PCREParser.NameContext)
/**
* Exit a parse tree produced by {@link PCREParser#name}.
- Parameters:
- ctx: the parse tree
*/
func exitName(_ ctx: PCREParser.NameContext)
/**
* Enter a parse tree produced by {@link PCREParser#alpha_nums}.
- Parameters:
- ctx: the parse tree
*/
func enterAlpha_nums(_ ctx: PCREParser.Alpha_numsContext)
/**
* Exit a parse tree produced by {@link PCREParser#alpha_nums}.
- Parameters:
- ctx: the parse tree
*/
func exitAlpha_nums(_ ctx: PCREParser.Alpha_numsContext)
/**
* Enter a parse tree produced by {@link PCREParser#non_close_parens}.
- Parameters:
- ctx: the parse tree
*/
func enterNon_close_parens(_ ctx: PCREParser.Non_close_parensContext)
/**
* Exit a parse tree produced by {@link PCREParser#non_close_parens}.
- Parameters:
- ctx: the parse tree
*/
func exitNon_close_parens(_ ctx: PCREParser.Non_close_parensContext)
/**
* Enter a parse tree produced by {@link PCREParser#non_close_paren}.
- Parameters:
- ctx: the parse tree
*/
func enterNon_close_paren(_ ctx: PCREParser.Non_close_parenContext)
/**
* Exit a parse tree produced by {@link PCREParser#non_close_paren}.
- Parameters:
- ctx: the parse tree
*/
func exitNon_close_paren(_ ctx: PCREParser.Non_close_parenContext)
/**
* Enter a parse tree produced by {@link PCREParser#letter}.
- Parameters:
- ctx: the parse tree
*/
func enterLetter(_ ctx: PCREParser.LetterContext)
/**
* Exit a parse tree produced by {@link PCREParser#letter}.
- Parameters:
- ctx: the parse tree
*/
func exitLetter(_ ctx: PCREParser.LetterContext)
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,56 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Foundation
public final class RegexPlaceholderGenerator {
public static func generatePlaceholder(matrixOfSymbols: [[Character]]) -> String {
var placeholderStringBuilder = String()
var indexes = [Array<Character>: Int]()
matrixOfSymbols.forEach { listOfSymbols in
indexes[listOfSymbols] = 0
}
matrixOfSymbols.filter { !$0.isEmpty }.forEach { listOfSymbols in
if listOfSymbols.count == 1 {
placeholderStringBuilder.append(listOfSymbols[0])
return
}
if let index = indexes[listOfSymbols] {
var newIndex = index
if listOfSymbols.count <= newIndex {
newIndex = 0
}
placeholderStringBuilder.append(listOfSymbols[newIndex])
newIndex += 1
indexes[listOfSymbols] = newIndex
}
}
return placeholderStringBuilder
}
}

View File

@ -0,0 +1,28 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Foundation
public struct PCREGeneratorItem {
public let regexReplaceString: String
public let matrixOfSymbols: [[Character]]
}

View File

@ -0,0 +1,185 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Foundation
import Antlr4
public final class PCREGeneratorListener: PCREBaseListener {
// MARK: - Properties
/*
Matrix of available symbols for placeholder where
index - symbol number and value - all available symbols
*/
private var matrixOfSymbols = [[Character]]()
/*
Regex group index counter, 1 by default
*/
private var currentGroupIndex = 1
/*
The final output replacement of the entered regex
*/
private var regexReplaceString = ""
/*
Search element from the regex
Could contain possible elements of a regex, e.g.:
[1-2], \\d, [A-B] and elements not related to regex or escaped
*/
private var listOfSymbols = [Character]()
// MARK: - Overrides
/*
Called when a new capture group found
*/
public override func enterCapture(_ ctx: PCREParser.CaptureContext) {
super.enterCapture(ctx)
regexReplaceString += "$\(currentGroupIndex)"
currentGroupIndex += 1
}
/*
Called when there is a digit symbol found, e.g.:
\d{2} where \d is an indication of a digit symbol
*/
public override func enterShared_atom(_ ctx: PCREParser.Shared_atomContext) {
super.enterShared_atom(ctx)
listOfSymbols = "1234567890".map { Character(String($0)) }
matrixOfSymbols.append(listOfSymbols)
}
/*
Called when there is a range found, e.g.:
[А-дD-f] or [А-д]
*/
public override func enterCharacter_class(_ ctx: PCREParser.Character_classContext) {
super.enterCharacter_class(ctx)
// Range count validation
// - true if [А-дD-f]
// - false if [А-д]
if ctx.cc_atom().count > 1 {
listOfSymbols = []
guard let firstChar = ctx.CharacterClassStart()?.getText() else {
listOfSymbols = getAvailableSymbols(for: ctx.getText())
return
}
let endChar = ctx.CharacterClassEnd()[0].getText()
for i in 0 ..< ctx.cc_atom().count {
listOfSymbols += getAvailableSymbols(for: firstChar + ctx.cc_atom()[i].getText() + endChar)
}
} else {
listOfSymbols = getAvailableSymbols(for: ctx.getText())
}
matrixOfSymbols.append(listOfSymbols)
}
/*
Called when there is a number of element duplication found, e.g.:
[A-B]{6} where {6} is a number of required element duplication
*/
public override func enterQuantifier(_ ctx: PCREParser.QuantifierContext) {
super.enterQuantifier(ctx)
var count = 1
/*
If there is a {1,2} duplication then take the last one to maximize the output placeholder
*/
if let quantifierString = ctx.getText().components(separatedBy: CharacterSet.decimalDigits.inverted).filter({ !$0.isEmpty }).last,
let quantifier = Int(quantifierString) {
count = quantifier
}
/*
If there is an infinite duplication option through "+" sign then duplicate it 5 times
*/
if ctx.getText() == "+" {
count = 5
}
for _ in 1 ..< count {
matrixOfSymbols.append(listOfSymbols)
}
}
/*
Called when there is a single non-group literal found, e.g.:
(?:\\+7 ) where "+", "7" and " " are single non-group literals
*/
public override func enterLiteral(_ ctx: PCREParser.LiteralContext) {
super.enterLiteral(ctx)
guard let text = ctx.shared_literal()?.getText() else {
return
}
regexReplaceString += text
listOfSymbols = []
ctx.getText().forEach { symbol in
listOfSymbols.append(symbol)
}
matrixOfSymbols.append(listOfSymbols)
}
// MARK: - Public methods
public func toPCREGeneratorItem() -> PCREGeneratorItem {
return PCREGeneratorItem(regexReplaceString: regexReplaceString,
matrixOfSymbols: matrixOfSymbols.map { $0.filter { $0 != "\\" } })
}
// MARK: - Private methods
private func getAvailableSymbols(for ctxText: String) -> [Character] {
let startAtomStr = ctxText[ctxText.index(after: ctxText.startIndex)]
let endAtomStr = ctxText[ctxText.index(ctxText.endIndex, offsetBy: -2)]
guard (startAtomStr.isLetter || startAtomStr.isNumber) && (endAtomStr.isLetter || endAtomStr.isNumber) else {
return [startAtomStr, endAtomStr]
}
guard let startRangeScalar = startAtomStr.unicodeScalars.first?.value,
let endRangeScalar = endAtomStr.unicodeScalars.first?.value else {
return [startAtomStr, endAtomStr]
}
let symbols = (startRangeScalar...endRangeScalar)
.compactMap(UnicodeScalar.init)
.map(Character.init)
.filter { $0.isLetter || $0.isNumber }
return symbols
}
}

View File

@ -0,0 +1,45 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Foundation
import Antlr4
public final class RegexReplaceGenerator {
public static func generateReplacement(for regex: String) -> PCREGeneratorItem {
let inputStream = ANTLRInputStream(regex)
let lexer = PCRELexer(inputStream)
let tokens = CommonTokenStream(lexer)
let walker = ParseTreeWalker()
let pcreGeneratorListener = PCREGeneratorListener()
let parser = try? PCREParser(tokens)
guard let parseContext = try? parser?.parse() as? ParseTree else {
fatalError("Cannot parse input regex")
}
try? walker.walk(pcreGeneratorListener, parseContext)
return pcreGeneratorListener.toPCREGeneratorItem()
}
}

View File

@ -0,0 +1,53 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import Foundation
public final class TextFormatter {
private let regex: String
public init(regex: String) {
self.regex = regex
}
public func getRegexReplacement() -> String {
RegexReplaceGenerator.generateReplacement(for: regex).regexReplaceString
}
public func getRegexPlaceholder() -> String {
let matrixOfSymbols = RegexReplaceGenerator.generateReplacement(for: regex).matrixOfSymbols
return RegexPlaceholderGenerator.generatePlaceholder(matrixOfSymbols: matrixOfSymbols)
}
public func getFormattedText(_ text: String) -> String {
guard let expression = try? NSRegularExpression(pattern: regex, options: .caseInsensitive) else {
fatalError("Cannot create NSRegularExpression from input regex")
}
return expression.stringByReplacingMatches(in: text,
options: .reportProgress,
range: NSMakeRange(0, text.count),
withTemplate: getRegexReplacement())
}
}

View File

@ -0,0 +1,18 @@
Pod::Spec.new do |s|
s.name = 'TITextProcessing'
s.version = '1.43.0'
s.summary = 'A text processing service helping to get a text mask and a placeholder from incoming regex.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'petropavel13' => 'ivan.smolin@touchin.ru' }
s.source = { :git => 'https://git.svc.touchin.ru/TouchInstinct/LeadKit.git', :tag => s.version.to_s }
s.ios.deployment_target = '10.0'
s.swift_versions = ['5.3']
s.source_files = s.name + '/Sources/**/*'
s.static_framework = true
s.user_target_xcconfig = { 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.pod_target_xcconfig = { 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
end

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIUIElements'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Bunch of useful protocols and views.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIUIKitCore'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Core UI elements: protocols, views and helpers.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIWebView'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Universal web view API'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TIYandexMapUtils'
s.version = '1.42.1'
s.version = '1.43.0'
s.summary = 'Set of helpers for map objects clustering and interacting using Yandex Maps SDK.'
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/LeadKit/tree/' + s.version.to_s + '/' + s.name
s.license = { :type => 'MIT', :file => 'LICENSE' }

View File

@ -0,0 +1,146 @@
//
// Copyright (c) 2023 Touch Instinct
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the Software), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
import XCTest
@testable import TITextProcessing
final class TITextProcessingTests: XCTestCase {
func testDateRegex() {
// given
let regex = "(\\d{2})\\/?(\\d{2})"
let inputText = "1525"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1\\/$2")
XCTAssertEqual(regexPlaceholder, "12/34")
XCTAssertEqual(formattedText, "15/25")
}
func testCardNumberRegex() {
// given
let regex = "(\\d{4}) ?(\\d{4}) ?(\\d{4}) ?(\\d{4})"
let inputText = "2200111555550080"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1 $2 $3 $4")
XCTAssertEqual(regexPlaceholder, "1234 5678 9012 3456")
XCTAssertEqual(formattedText, "2200 1115 5555 0080")
}
func testPhoneNumberRegex() {
// given
let regex = "(?:\\+7 )?\\(?(\\d{3})\\)? ?(\\d{3}) ?(\\d{2}) ?(\\d{2})"
let inputText = "9995534820"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "\\+7 \\($1\\) $2 $3 $4")
XCTAssertEqual(regexPlaceholder, "+7 (123) 456 78 90")
XCTAssertEqual(formattedText, "+7 (999) 553 48 20")
}
func testBirthdayCertificateRegex() {
// given
let regex = "([A-Z]{2})-?([А-Я]{2}) ?№? ?(\\d{6})"
let inputText = "ABЮЯ689323"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1-$2 № $3")
XCTAssertEqual(regexPlaceholder, "AB-АБ № 123456")
XCTAssertEqual(formattedText, "AB-ЮЯ № 689323")
}
func testRoubleSumRegex() {
// given
let regex = "(\\d+)([.,]\\d{1,2})? ?₽?"
let inputText = "5332.4"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1$2 ₽")
XCTAssertEqual(regexPlaceholder, "12345.67 ₽")
XCTAssertEqual(formattedText, "5332.4 ₽")
}
func testSurnameRegex() {
// given
let regex = "([А-я]+)"
let inputText = "Иванов"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1")
XCTAssertEqual(regexPlaceholder, "АБВГД")
XCTAssertEqual(formattedText, "Иванов")
}
func testEmailRegex() {
// given
let regex = "([A-z0-9._%+-]+)@([A-z0-9.-]+)\\.([A-z]{2,})"
let inputText = "test@test.com"
let formatter = TextFormatter(regex: regex)
// when
let regexReplacement = formatter.getRegexReplacement()
let regexPlaceholder = formatter.getRegexPlaceholder()
let formattedText = formatter.getFormattedText(inputText)
// then
XCTAssertEqual(regexReplacement, "$1@$2\\.$3")
XCTAssertEqual(regexPlaceholder, "ABCDE@ABCDE.AB")
XCTAssertEqual(formattedText, "test@test.com")
}
}

View File

@ -18,3 +18,4 @@ TIEcommerce
TIWebView
TIDeveloperUtils
TIDeeplink
TITextProcessing