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.
- checksums.yaml +4 -4
- data/README.md +390 -216
- data/lib/feen/dumper/games_turn.rb +32 -29
- data/lib/feen/dumper/piece_placement.rb +85 -63
- data/lib/feen/dumper/pieces_in_hand.rb +91 -62
- data/lib/feen/dumper.rb +2 -2
- data/lib/feen/parser/games_turn.rb +36 -16
- data/lib/feen/parser/piece_placement.rb +78 -564
- data/lib/feen/parser/pieces_in_hand.rb +104 -138
- data/lib/feen/parser.rb +3 -3
- data/lib/feen.rb +20 -9
- metadata +1 -11
- data/lib/feen/dumper/pieces_in_hand/errors.rb +0 -12
- data/lib/feen/dumper/pieces_in_hand/no_pieces.rb +0 -10
- data/lib/feen/parser/games_turn/errors.rb +0 -14
- data/lib/feen/parser/games_turn/valid_games_turn_pattern.rb +0 -24
- data/lib/feen/parser/pieces_in_hand/canonical_sorter.rb +0 -70
- data/lib/feen/parser/pieces_in_hand/errors.rb +0 -17
- data/lib/feen/parser/pieces_in_hand/no_pieces.rb +0 -10
- data/lib/feen/parser/pieces_in_hand/piece_count_pattern.rb +0 -13
- data/lib/feen/parser/pieces_in_hand/pnn_patterns.rb +0 -47
- data/lib/feen/parser/pieces_in_hand/valid_format_pattern.rb +0 -29
@@ -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
|