tree-sitter-pgn 1.0.12__tar.gz → 1.0.14__tar.gz

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.

Files changed (23) hide show
  1. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/PKG-INFO +42 -2
  2. tree_sitter_pgn-1.0.14/README.md +61 -0
  3. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/PKG-INFO +42 -2
  4. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/SOURCES.txt +1 -0
  5. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/pyproject.toml +1 -1
  6. tree_sitter_pgn-1.0.14/src/parser.c +22583 -0
  7. tree_sitter_pgn-1.0.14/src/scanner.c +39 -0
  8. tree_sitter_pgn-1.0.12/README.md +0 -21
  9. tree_sitter_pgn-1.0.12/src/parser.c +0 -17367
  10. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/LICENSE +0 -0
  11. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn/__init__.py +0 -0
  12. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn/__init__.pyi +0 -0
  13. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn/binding.c +0 -0
  14. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn/py.typed +0 -0
  15. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/dependency_links.txt +0 -0
  16. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/not-zip-safe +0 -0
  17. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/requires.txt +0 -0
  18. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/bindings/python/tree_sitter_pgn.egg-info/top_level.txt +0 -0
  19. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/setup.cfg +0 -0
  20. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/setup.py +0 -0
  21. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/src/tree_sitter/alloc.h +0 -0
  22. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/src/tree_sitter/array.h +0 -0
  23. {tree_sitter_pgn-1.0.12 → tree_sitter_pgn-1.0.14}/src/tree_sitter/parser.h +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tree-sitter-pgn
3
- Version: 1.0.12
3
+ Version: 1.0.14
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)
@@ -0,0 +1,61 @@
1
+ # tree-sitter-pgn
2
+
3
+ ## Overview
4
+
5
+ Chess Portable Game Notation (PGN) grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
6
+
7
+ ## Used in
8
+
9
+ * [Emacs pygn-mode](https://github.com/dwcoates/pygn-mode)
10
+
11
+ ## Highlighting Example
12
+
13
+ <a href="/doc/images/pgn_syntax_highlight.png">
14
+ <img src="/doc/images/pgn_syntax_highlight.png" width=500/>
15
+ </a>
16
+
17
+ ## Python Example
18
+
19
+ ```python
20
+ import more_itertools
21
+ from tree_sitter import Language, Parser
22
+ import tree_sitter_pgn as ts_pgn
23
+
24
+ PGN_LANGUAGE = Language(ts_pgn.language())
25
+ parser = Parser(PGN_LANGUAGE)
26
+
27
+ query = PGN_LANGUAGE.query(
28
+ '''
29
+ (series_of_games
30
+ game: (game) @game)
31
+
32
+ (movetext
33
+ san_move: (san_move) @san_move)
34
+ ''')
35
+
36
+ with open('input_file.pgn', 'rb') as file:
37
+ content = b''.join(file.readlines())
38
+ tree = parser.parse(content)
39
+
40
+ matches = query.captures(tree.root_node)
41
+
42
+ merged_nodes = [
43
+ *matches.get('game', []),
44
+ *matches.get('san_move', []),
45
+ ]
46
+ merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
47
+
48
+ for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
49
+ san = []
50
+ for node in game:
51
+ if node.type == 'san_move' and node.text is not None:
52
+ san.append(node.text.decode().strip())
53
+ continue
54
+ print(' '.join(san))
55
+ ```
56
+
57
+ ## References
58
+
59
+ * [PGN specification](http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm)
60
+ * [Commonly-used extensions](https://www.enpassant.dk/chess/palview/enhancedpgn.htm)
61
+ * [Commonly-used annotation glyphs](https://en.wikipedia.org/wiki/Numeric_Annotation_Glyphs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tree-sitter-pgn
3
- Version: 1.0.12
3
+ Version: 1.0.14
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)
@@ -13,6 +13,7 @@ bindings/python/tree_sitter_pgn.egg-info/not-zip-safe
13
13
  bindings/python/tree_sitter_pgn.egg-info/requires.txt
14
14
  bindings/python/tree_sitter_pgn.egg-info/top_level.txt
15
15
  src/parser.c
16
+ src/scanner.c
16
17
  src/tree_sitter/alloc.h
17
18
  src/tree_sitter/array.h
18
19
  src/tree_sitter/parser.h
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  name = "tree-sitter-pgn"
7
7
  description = "PGN grammar for tree-sitter"
8
- version = "1.0.12"
8
+ version = "1.0.14"
9
9
  keywords = ["incremental", "parsing", "tree-sitter", "PGN", "chess"]
10
10
  classifiers = [
11
11
  "Intended Audience :: Developers",