tree-sitter-pgn 1.0.12__cp38-abi3-macosx_10_9_x86_64.whl → 1.0.13__cp38-abi3-macosx_10_9_x86_64.whl
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.
Potentially problematic release.
This version of tree-sitter-pgn might be problematic. Click here for more details.
- tree_sitter_pgn/_binding.abi3.so +0 -0
- {tree_sitter_pgn-1.0.12.dist-info → tree_sitter_pgn-1.0.13.dist-info}/METADATA +42 -2
- {tree_sitter_pgn-1.0.12.dist-info → tree_sitter_pgn-1.0.13.dist-info}/RECORD +6 -6
- {tree_sitter_pgn-1.0.12.dist-info → tree_sitter_pgn-1.0.13.dist-info}/LICENSE +0 -0
- {tree_sitter_pgn-1.0.12.dist-info → tree_sitter_pgn-1.0.13.dist-info}/WHEEL +0 -0
- {tree_sitter_pgn-1.0.12.dist-info → tree_sitter_pgn-1.0.13.dist-info}/top_level.txt +0 -0
tree_sitter_pgn/_binding.abi3.so
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tree-sitter-pgn
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.13
|
|
4
4
|
Summary: PGN grammar for tree-sitter
|
|
5
5
|
License: BSD
|
|
6
6
|
Project-URL: Homepage, https://github.com/rolandwalker/tree-sitter-pgn
|
|
@@ -26,12 +26,52 @@ Chess Portable Game Notation (PGN) grammar for [tree-sitter](https://github.com/
|
|
|
26
26
|
|
|
27
27
|
* [Emacs pygn-mode](https://github.com/dwcoates/pygn-mode)
|
|
28
28
|
|
|
29
|
-
## Example
|
|
29
|
+
## Highlighting Example
|
|
30
30
|
|
|
31
31
|
<a href="/doc/images/pgn_syntax_highlight.png">
|
|
32
32
|
<img src="/doc/images/pgn_syntax_highlight.png" width=500/>
|
|
33
33
|
</a>
|
|
34
34
|
|
|
35
|
+
## Python Example
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
import more_itertools
|
|
39
|
+
from tree_sitter import Language, Parser
|
|
40
|
+
import tree_sitter_pgn as ts_pgn
|
|
41
|
+
|
|
42
|
+
PGN_LANGUAGE = Language(ts_pgn.language())
|
|
43
|
+
parser = Parser(PGN_LANGUAGE)
|
|
44
|
+
|
|
45
|
+
query = PGN_LANGUAGE.query(
|
|
46
|
+
'''
|
|
47
|
+
(series_of_games
|
|
48
|
+
game: (game) @game)
|
|
49
|
+
|
|
50
|
+
(movetext
|
|
51
|
+
san_move: (san_move) @san_move)
|
|
52
|
+
''')
|
|
53
|
+
|
|
54
|
+
with open('input_file.pgn', 'rb') as file:
|
|
55
|
+
content = b''.join(file.readlines())
|
|
56
|
+
tree = parser.parse(content)
|
|
57
|
+
|
|
58
|
+
matches = query.captures(tree.root_node)
|
|
59
|
+
|
|
60
|
+
merged_nodes = [
|
|
61
|
+
*matches.get('game', []),
|
|
62
|
+
*matches.get('san_move', []),
|
|
63
|
+
]
|
|
64
|
+
merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
|
|
65
|
+
|
|
66
|
+
for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
|
|
67
|
+
san = []
|
|
68
|
+
for node in game:
|
|
69
|
+
if node.type == 'san_move' and node.text is not None:
|
|
70
|
+
san.append(node.text.decode().strip())
|
|
71
|
+
continue
|
|
72
|
+
print(' '.join(san))
|
|
73
|
+
```
|
|
74
|
+
|
|
35
75
|
## References
|
|
36
76
|
|
|
37
77
|
* [PGN specification](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm)
|
|
@@ -2,10 +2,10 @@ tree_sitter_pgn/__init__.pyi,sha256=8xf7bY1szgDY9HRJ7FJ326So4SFgMiSRfCB4LADkTpU,
|
|
|
2
2
|
tree_sitter_pgn/binding.c,sha256=f0wnkjshn03m8OnEMcCgHzXlieObCAo50sacARwJ4-Y,677
|
|
3
3
|
tree_sitter_pgn/__init__.py,sha256=ZiLr1Q0znhhSjnr-HOQ9eYQGPl377jelB9rBPHWpUFc,86
|
|
4
4
|
tree_sitter_pgn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
tree_sitter_pgn/_binding.abi3.so,sha256=
|
|
5
|
+
tree_sitter_pgn/_binding.abi3.so,sha256=RrXORYno4qGj2k7OITTYkvL_DXeWn6gqkpw79NxNnp4,182936
|
|
6
6
|
tree_sitter_pgn/queries/highlights.scm,sha256=f0ZNijh1NqOo3M4c2ChC0ra5SjPtFmR0CJg_-gcrSUU,676
|
|
7
|
-
tree_sitter_pgn-1.0.
|
|
8
|
-
tree_sitter_pgn-1.0.
|
|
9
|
-
tree_sitter_pgn-1.0.
|
|
10
|
-
tree_sitter_pgn-1.0.
|
|
11
|
-
tree_sitter_pgn-1.0.
|
|
7
|
+
tree_sitter_pgn-1.0.13.dist-info/RECORD,,
|
|
8
|
+
tree_sitter_pgn-1.0.13.dist-info/LICENSE,sha256=OQC_60bW3_K5dikbtjNFxNBdIsqGpiKnMdnRlEZW9pY,1323
|
|
9
|
+
tree_sitter_pgn-1.0.13.dist-info/WHEEL,sha256=N3RZ2XnlTS_1KEj1Ig2aE6hf95tup1alXGfeyscmPhw,109
|
|
10
|
+
tree_sitter_pgn-1.0.13.dist-info/top_level.txt,sha256=GT5VMTItAEXgTjoJj2gP_fQVqZd7tY5TIRpOgyp1zlU,25
|
|
11
|
+
tree_sitter_pgn-1.0.13.dist-info/METADATA,sha256=D3xEcdb6D3K7viok2KpwHIlikrvLuRhwZOrHi-AeIz4,2203
|
|
File without changes
|
|
File without changes
|
|
File without changes
|