feen 5.0.0.beta6 → 5.0.0.beta8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feen
4
- module Parser
5
- module PiecesInHand
6
- # Patterns for PNN (Piece Name Notation) validation and parsing
7
- module PnnPatterns
8
- # Basic PNN piece pattern following the specification:
9
- # <piece> ::= <letter> | <prefix> <letter> | <letter> <suffix> | <prefix> <letter> <suffix>
10
- # <prefix> ::= "+" | "-"
11
- # <suffix> ::= "'"
12
- # <letter> ::= [a-zA-Z]
13
- PNN_PIECE_PATTERN = /\A[-+]?[a-zA-Z]'?\z/
14
-
15
- # Pattern for valid count prefixes according to FEEN specification:
16
- # - Cannot be "0" or "1" (use piece without prefix instead)
17
- # - Can be 2-9 or any number with 2+ digits
18
- VALID_COUNT_PATTERN = /\A(?:[2-9]|\d{2,})\z/
19
-
20
- # Pattern to extract piece with optional count from pieces in hand string
21
- # Matches: optional count followed by complete PNN piece
22
- # Groups: (count_str, piece_str)
23
- # Note: We need to handle the full PNN piece including modifiers
24
- PIECE_WITH_COUNT_PATTERN = /(?:([2-9]|\d{2,}))?([-+]?[a-zA-Z]'?)/
25
-
26
- # Complete validation pattern for pieces in hand string
27
- # Based on the FEEN BNF specification with PNN support
28
- # This pattern allows any sequence of pieces (uppercase/lowercase mixed) in canonical order
29
- # It should reject invalid formats like "++P"
30
- VALID_FORMAT_PATTERN = /\A
31
- (?:
32
- -| # No pieces in hand
33
- (?:
34
- (?:[2-9]|\d{2,})? # Optional count (2-9 or 10+)
35
- [-+]? # Optional single prefix (+ or -)
36
- [a-zA-Z] # Required letter
37
- '? # Optional single suffix (')
38
- )+ # One or more pieces
39
- )
40
- \z/x
41
-
42
- # Pattern for extracting all pieces globally (used for comprehensive validation)
43
- GLOBAL_PIECE_EXTRACTION_PATTERN = /(?:([2-9]|\d{2,}))?([-+]?[a-zA-Z]'?)/
44
- end
45
- end
46
- end
47
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Feen
4
- module Parser
5
- module PiecesInHand
6
- # Valid pattern for pieces in hand based on BNF specification.
7
- #
8
- # The FEEN format specifies these rules for numeric prefixes:
9
- # - Cannot start with "0"
10
- # - Cannot be exactly "1" (use the letter without prefix instead)
11
- # - Can be 2-9 or any number with 2+ digits (10, 11, etc.)
12
- #
13
- # The pattern matches either:
14
- # - A single digit from 2-9
15
- # - OR any number with two or more digits (10, 11, 27, 103, etc.)
16
- #
17
- # @return [Regexp] Regular expression for validating pieces in hand format
18
- ValidFormatPattern = /\A
19
- (?:
20
- -| # No pieces in hand
21
- (?: # Or sequence of pieces
22
- (?:(?:[2-9]|\d{2,})?[A-Z])* # Uppercase pieces (optional)
23
- (?:(?:[2-9]|\d{2,})?[a-z])* # Lowercase pieces (optional)
24
- )
25
- )
26
- \z/x
27
- end
28
- end
29
- end