Skip to content

Commit

Permalink
Update constants
Browse files Browse the repository at this point in the history
TODO: Add them to API
  • Loading branch information
ltrzesniewski committed Dec 29, 2024
1 parent a6f950f commit c2882d3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This is a friendly API that is very similar to .NET's `System.Text.RegularExpres
- Callbacks: `Func<PcreMatch, string>`
- Replacement strings with placeholders: ``$n ${name} $& $_ $` $' $+``
- Using `Substitute`, the PCRE2 API:
- Replacement strings with placeholders: ``$n ${n} $$ $*MARK ${*MARK}``
- Replacement strings with placeholders: ``$n ${n} $& $_ $` $' $$ $*MARK ${*MARK}``
- Callouts for matches and substitutions
- String splitting on matches: `Split`

Expand Down
39 changes: 38 additions & 1 deletion src/PCRE.NET/Internal/PcreConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal static class PcreConstants
public const uint EXTENDED_MORE = 0x01000000;
public const uint LITERAL = 0x02000000;
public const uint MATCH_INVALID_UTF = 0x04000000;
public const uint ALT_EXTENDED_CLASS = 0x08000000;
public const uint EXTRA_ALLOW_SURROGATE_ESCAPES = 0x00000001;
public const uint EXTRA_BAD_ESCAPE_IS_LITERAL = 0x00000002;
public const uint EXTRA_MATCH_WORD = 0x00000004;
Expand All @@ -53,10 +54,15 @@ internal static class PcreConstants
public const uint EXTRA_ASCII_BSW = 0x00000400;
public const uint EXTRA_ASCII_POSIX = 0x00000800;
public const uint EXTRA_ASCII_DIGIT = 0x00001000;
public const uint EXTRA_PYTHON_OCTAL = 0x00002000;
public const uint EXTRA_NO_BS0 = 0x00004000;
public const uint EXTRA_NEVER_CALLOUT = 0x00008000;
public const uint EXTRA_TURKISH_CASING = 0x00010000;
public const uint JIT_COMPLETE = 0x00000001;
public const uint JIT_PARTIAL_SOFT = 0x00000002;
public const uint JIT_PARTIAL_HARD = 0x00000004;
public const uint JIT_INVALID_UTF = 0x00000100;
public const uint JIT_TEST_ALLOC = 0x00000200;
public const uint NOTBOL = 0x00000001;
public const uint NOTEOL = 0x00000002;
public const uint NOTEMPTY = 0x00000004;
Expand Down Expand Up @@ -188,8 +194,25 @@ internal static class PcreConstants
public const int ERROR_ALPHA_ASSERTION_UNKNOWN = 195;
public const int ERROR_SCRIPT_RUN_NOT_AVAILABLE = 196;
public const int ERROR_TOO_MANY_CAPTURES = 197;
public const int ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED = 198;
public const int ERROR_MISSING_OCTAL_DIGIT = 198;
public const int ERROR_BACKSLASH_K_IN_LOOKAROUND = 199;
public const int ERROR_MAX_VAR_LOOKBEHIND_EXCEEDED = 200;
public const int ERROR_PATTERN_COMPILED_SIZE_TOO_BIG = 201;
public const int ERROR_OVERSIZE_PYTHON_OCTAL = 202;
public const int ERROR_CALLOUT_CALLER_DISABLED = 203;
public const int ERROR_EXTRA_CASING_REQUIRES_UNICODE = 204;
public const int ERROR_TURKISH_CASING_REQUIRES_UTF = 205;
public const int ERROR_EXTRA_CASING_INCOMPATIBLE = 206;
public const int ERROR_ECLASS_NEST_TOO_DEEP = 207;
public const int ERROR_ECLASS_INVALID_OPERATOR = 208;
public const int ERROR_ECLASS_UNEXPECTED_OPERATOR = 209;
public const int ERROR_ECLASS_EXPECTED_OPERAND = 210;
public const int ERROR_ECLASS_MIXED_OPERATORS = 211;
public const int ERROR_ECLASS_HINT_SQUARE_BRACKET = 212;
public const int ERROR_PERL_ECLASS_UNEXPECTED_EXPR = 213;
public const int ERROR_PERL_ECLASS_EMPTY_EXPR = 214;
public const int ERROR_PERL_ECLASS_MISSING_CLOSE = 215;
public const int ERROR_PERL_ECLASS_UNEXPECTED_CHAR = 216;
public const int ERROR_NOMATCH = -1;
public const int ERROR_PARTIAL = -2;
public const int ERROR_UTF8_ERR1 = -3;
Expand Down Expand Up @@ -257,6 +280,9 @@ internal static class PcreConstants
public const int ERROR_INTERNAL_DUPMATCH = -65;
public const int ERROR_DFA_UINVALID_UTF = -66;
public const int ERROR_INVALIDOFFSET = -67;
public const int ERROR_JIT_UNSUPPORTED = -68;
public const int ERROR_REPLACECASE = -69;
public const int ERROR_TOOLARGEREPLACE = -70;
public const uint INFO_ALLOPTIONS = 0;
public const uint INFO_ARGOPTIONS = 1;
public const uint INFO_BACKREFMAX = 2;
Expand Down Expand Up @@ -299,6 +325,17 @@ internal static class PcreConstants
public const uint CONFIG_NEVER_BACKSLASH_C = 13;
public const uint CONFIG_COMPILED_WIDTHS = 14;
public const uint CONFIG_TABLES_LENGTH = 15;
public const uint OPTIMIZATION_NONE = 0;
public const uint OPTIMIZATION_FULL = 1;
public const uint AUTO_POSSESS = 64;
public const uint AUTO_POSSESS_OFF = 65;
public const uint DOTSTAR_ANCHOR = 66;
public const uint DOTSTAR_ANCHOR_OFF = 67;
public const uint START_OPTIMIZE = 68;
public const uint START_OPTIMIZE_OFF = 69;
public const uint SUBSTITUTE_CASE_LOWER = 1;
public const uint SUBSTITUTE_CASE_UPPER = 2;
public const uint SUBSTITUTE_CASE_TITLE_FIRST = 3;
public const uint CALLOUT_STARTMATCH = 0x00000001;
public const uint CALLOUT_BACKTRACK = 0x00000002;
}
9 changes: 8 additions & 1 deletion src/PCRE.NET/PcreErrorCode.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Diagnostics.CodeAnalysis;
using PCRE.Internal;

Expand Down Expand Up @@ -501,10 +502,16 @@ public enum PcreErrorCode
/// </summary>
TooManyCaptures = PcreConstants.ERROR_TOO_MANY_CAPTURES,

/// <summary>
/// <c>PCRE2_ERROR_MISSING_OCTAL_DIGIT</c> - Octal digit missing after <c>\0</c> (PCRE2_EXTRA_NO_BS0 is set).
/// </summary>
MissingOctalDigit = PcreConstants.ERROR_MISSING_OCTAL_DIGIT,

/// <summary>
/// <c>PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED</c> - Atomic assertion expected after <c>(?(</c> or <c>(?(?C)</c>
/// </summary>
ConditionAtomicAssertionExpected = PcreConstants.ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED,
[Obsolete($"Not used anymore, shares the code with {nameof(MissingOctalDigit)}")]
ConditionAtomicAssertionExpected = MissingOctalDigit,

/// <summary>
/// <c>PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND</c> - <c>\K</c> is not allowed in lookarounds (but see <see cref="PcreExtraCompileOptions.AllowLookaroundBsK"/>).
Expand Down

0 comments on commit c2882d3

Please sign in to comment.