tree-sitter-pgn 1.0.16__tar.gz → 1.1.0__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 (22) hide show
  1. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/PKG-INFO +10 -7
  2. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/README.md +9 -6
  3. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/PKG-INFO +10 -7
  4. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/pyproject.toml +1 -1
  5. tree_sitter_pgn-1.1.0/src/parser.c +28056 -0
  6. tree_sitter_pgn-1.0.16/src/parser.c +0 -22583
  7. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/LICENSE +0 -0
  8. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn/__init__.py +0 -0
  9. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn/__init__.pyi +0 -0
  10. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn/binding.c +0 -0
  11. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn/py.typed +0 -0
  12. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/SOURCES.txt +0 -0
  13. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/dependency_links.txt +0 -0
  14. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/not-zip-safe +0 -0
  15. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/requires.txt +0 -0
  16. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/bindings/python/tree_sitter_pgn.egg-info/top_level.txt +0 -0
  17. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/setup.cfg +0 -0
  18. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/setup.py +0 -0
  19. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/src/scanner.c +0 -0
  20. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/src/tree_sitter/alloc.h +0 -0
  21. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/src/tree_sitter/array.h +0 -0
  22. {tree_sitter_pgn-1.0.16 → tree_sitter_pgn-1.1.0}/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.16
3
+ Version: 1.1.0
4
4
  Summary: PGN grammar for tree-sitter
5
5
  License: BSD
6
6
  Project-URL: Homepage, https://github.com/rolandwalker/tree-sitter-pgn
@@ -49,27 +49,30 @@ query = PGN_LANGUAGE.query(
49
49
 
50
50
  (movetext
51
51
  san_move: (san_move) @san_move)
52
+
53
+ (movetext
54
+ lan_move: (lan_move) @lan_move)
52
55
  ''')
53
56
 
54
57
  with open('input_file.pgn', 'rb') as file:
55
- content = b''.join(file.readlines())
56
- tree = parser.parse(content)
58
+ tree = parser.parse(file.read())
57
59
 
58
60
  matches = query.captures(tree.root_node)
59
61
 
60
62
  merged_nodes = [
61
63
  *matches.get('game', []),
62
64
  *matches.get('san_move', []),
65
+ *matches.get('lan_move', []),
63
66
  ]
64
67
  merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
65
68
 
66
69
  for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
67
- san = []
70
+ main_line = []
68
71
  for node in game:
69
- if node.type == 'san_move' and node.text is not None:
70
- san.append(node.text.decode().strip())
72
+ if node.type in ['san_move', 'lan_move'] and node.text is not None:
73
+ main_line.append(node.text.decode().strip())
71
74
  continue
72
- print(' '.join(san))
75
+ print(' '.join(main_line))
73
76
  ```
74
77
 
75
78
  ## References
@@ -31,27 +31,30 @@ query = PGN_LANGUAGE.query(
31
31
 
32
32
  (movetext
33
33
  san_move: (san_move) @san_move)
34
+
35
+ (movetext
36
+ lan_move: (lan_move) @lan_move)
34
37
  ''')
35
38
 
36
39
  with open('input_file.pgn', 'rb') as file:
37
- content = b''.join(file.readlines())
38
- tree = parser.parse(content)
40
+ tree = parser.parse(file.read())
39
41
 
40
42
  matches = query.captures(tree.root_node)
41
43
 
42
44
  merged_nodes = [
43
45
  *matches.get('game', []),
44
46
  *matches.get('san_move', []),
47
+ *matches.get('lan_move', []),
45
48
  ]
46
49
  merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
47
50
 
48
51
  for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
49
- san = []
52
+ main_line = []
50
53
  for node in game:
51
- if node.type == 'san_move' and node.text is not None:
52
- san.append(node.text.decode().strip())
54
+ if node.type in ['san_move', 'lan_move'] and node.text is not None:
55
+ main_line.append(node.text.decode().strip())
53
56
  continue
54
- print(' '.join(san))
57
+ print(' '.join(main_line))
55
58
  ```
56
59
 
57
60
  ## References
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tree-sitter-pgn
3
- Version: 1.0.16
3
+ Version: 1.1.0
4
4
  Summary: PGN grammar for tree-sitter
5
5
  License: BSD
6
6
  Project-URL: Homepage, https://github.com/rolandwalker/tree-sitter-pgn
@@ -49,27 +49,30 @@ query = PGN_LANGUAGE.query(
49
49
 
50
50
  (movetext
51
51
  san_move: (san_move) @san_move)
52
+
53
+ (movetext
54
+ lan_move: (lan_move) @lan_move)
52
55
  ''')
53
56
 
54
57
  with open('input_file.pgn', 'rb') as file:
55
- content = b''.join(file.readlines())
56
- tree = parser.parse(content)
58
+ tree = parser.parse(file.read())
57
59
 
58
60
  matches = query.captures(tree.root_node)
59
61
 
60
62
  merged_nodes = [
61
63
  *matches.get('game', []),
62
64
  *matches.get('san_move', []),
65
+ *matches.get('lan_move', []),
63
66
  ]
64
67
  merged_nodes = sorted(merged_nodes, key=lambda elt: elt.start_byte)
65
68
 
66
69
  for game in more_itertools.split_before(merged_nodes, lambda node: node.type == 'game'):
67
- san = []
70
+ main_line = []
68
71
  for node in game:
69
- if node.type == 'san_move' and node.text is not None:
70
- san.append(node.text.decode().strip())
72
+ if node.type in ['san_move', 'lan_move'] and node.text is not None:
73
+ main_line.append(node.text.decode().strip())
71
74
  continue
72
- print(' '.join(san))
75
+ print(' '.join(main_line))
73
76
  ```
74
77
 
75
78
  ## References
@@ -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.16"
8
+ version = "1.1.0"
9
9
  keywords = ["incremental", "parsing", "tree-sitter", "PGN", "chess"]
10
10
  classifiers = [
11
11
  "Intended Audience :: Developers",