SNOBOL4python 0.4.3__tar.gz → 0.4.5__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.
Files changed (23) hide show
  1. snobol4python-0.4.5/MANIFEST.in +14 -0
  2. {snobol4python-0.4.3/src/SNOBOL4python.egg-info → snobol4python-0.4.5}/PKG-INFO +3 -3
  3. {snobol4python-0.4.3 → snobol4python-0.4.5}/pyproject.toml +6 -3
  4. snobol4python-0.4.5/requirements.txt +3 -0
  5. {snobol4python-0.4.3 → snobol4python-0.4.5}/src/SNOBOL4python/SNOBOL4patterns.py +21 -13
  6. snobol4python-0.4.5/src/SNOBOL4python/deleteme.py +104 -0
  7. snobol4python-0.4.5/src/SNOBOL4python.egg-info/SOURCES.txt +14 -0
  8. snobol4python-0.4.3/PKG-INFO +0 -19
  9. snobol4python-0.4.3/src/SNOBOL4python.egg-info/SOURCES.txt +0 -18
  10. snobol4python-0.4.3/src/SNOBOL4python.egg-info/dependency_links.txt +0 -1
  11. snobol4python-0.4.3/src/SNOBOL4python.egg-info/top_level.txt +0 -1
  12. snobol4python-0.4.3/tests/test_icon-1.py +0 -152
  13. snobol4python-0.4.3/tests/test_icon-2.py +0 -115
  14. snobol4python-0.4.3/tests/test_icon-3.py +0 -29
  15. {snobol4python-0.4.3 → snobol4python-0.4.5}/LICENSE +0 -0
  16. {snobol4python-0.4.3 → snobol4python-0.4.5}/README.md +0 -0
  17. {snobol4python-0.4.3 → snobol4python-0.4.5}/setup.cfg +0 -0
  18. {snobol4python-0.4.3 → snobol4python-0.4.5}/src/SNOBOL4python/SNOBOL4functions.py +0 -0
  19. {snobol4python-0.4.3 → snobol4python-0.4.5}/src/SNOBOL4python/__init__.py +0 -0
  20. {snobol4python-0.4.3 → snobol4python-0.4.5}/tests/test_01.py +0 -0
  21. {snobol4python-0.4.3 → snobol4python-0.4.5}/tests/test_arbno.py +0 -0
  22. {snobol4python-0.4.3 → snobol4python-0.4.5}/tests/test_json.py +0 -0
  23. {snobol4python-0.4.3 → snobol4python-0.4.5}/tests/test_re_simple.py +0 -0
@@ -0,0 +1,14 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include src/SNOBOL4python *.py
4
+ recursive-include tests test_*.py
5
+ recursive-exclude misc test_*.py
6
+ global-exclude *.py[co]
7
+ global-exclude *.so
8
+ exclude .gitignore
9
+ exclude .pypirc
10
+ prune src/*.egg-info/
11
+ prune __pycache__/
12
+ prune *.egg-info/
13
+ prune build/
14
+ prune dist/
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: SNOBOL4python
3
- Version: 0.4.3
4
- Summary: A Python library for SNOBOL4-style pattern matching with regular expressions
3
+ Version: 0.4.5
4
+ Summary: A Python library for SNOBOL4-style pattern matching with support for regular expressions.
5
5
  Author-email: Lon Jones Cherryholmes <lcherryh@yahoo.com>
6
6
  License-Expression: GPL-3.0-or-later
7
7
  Project-URL: Homepage, https://github.com/LCherryholmes/SNOBOL4python
8
8
  Project-URL: Repository, https://github.com/LCherryholmes/SNOBOL4python
9
9
  Project-URL: Issues, https://github.com/LCherryholmes/SNOBOL4python/issues
10
- Keywords: python,SNOBOL,SNOBOL4,string pattern matching
10
+ Keywords: Python,SNOBOL,SNOBOL4,string pattern matching
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.10.0
13
13
  Description-Content-Type: text/markdown
@@ -4,18 +4,21 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "SNOBOL4python"
7
- version = "0.4.3"
8
- description = "A Python library for SNOBOL4-style pattern matching with regular expressions"
7
+ version = "0.4.5"
8
+ description = "A Python library for SNOBOL4-style pattern matching with support for regular expressions."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10.0"
11
11
  license = "GPL-3.0-or-later"
12
12
  authors = [{ name = "Lon Jones Cherryholmes", email = "lcherryh@yahoo.com" }]
13
- keywords = ["python", "SNOBOL", "SNOBOL4", "string pattern matching"]
13
+ keywords = ["Python", "SNOBOL", "SNOBOL4", "string pattern matching"]
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
16
  ]
17
17
  dependencies = []
18
18
 
19
+ [project-optional-dependencies]
20
+ test = ["pytest"]
21
+
19
22
  [project.urls]
20
23
  Homepage = "https://github.com/LCherryholmes/SNOBOL4python"
21
24
  Repository = "https://github.com/LCherryholmes/SNOBOL4python"
@@ -0,0 +1,3 @@
1
+ pytest==8.3.4
2
+ mkdocs-material==9.5.50
3
+ mkdocstrings[python]==0.27.0
@@ -7,8 +7,11 @@
7
7
  #> python -m pip install --upgrade setuptools wheel build
8
8
  #> python src/SNOBOL4python/SNOBOL4patterns.py
9
9
  #> python -m build
10
- #> python -m pip install ./dist/snobol4python-0.4.3.tar.gz
11
- #> python -m twine check dist/*
10
+ #> python -m pip install ./dist/snobol4python-0.4.5.tar.gz
11
+ #> python -m pip install ./dist/snobol4python-0.4.5-py3-none-any.whl
12
+ #> python -m pip install --index-url https://test.pypi.org/simple SNOBOL4python
13
+ #> python -m twine check ./dist/*
14
+ #> python -m twine upload ./dist/*
12
15
  #> python tests/test_01.py
13
16
  #> python tests/test_json.py
14
17
  #> python tests/test_arbno.py
@@ -46,6 +49,7 @@ class PATTERN(object):
46
49
  def __contains__(self, other): return SEARCH(other, self, exc=False) # comparison in operator, returns bool
47
50
  #----------------------------------------------------------------------------------------------------------------------
48
51
  class STRING(str):
52
+ def __repr__(self): return str.__repr__(self)
49
53
  def __add__(self, other): # SIGMA
50
54
  if isinstance(other, Σ): return Σ(σ(self), *other.AP)
51
55
  elif isinstance(other, str): return STRING(super().__add__(other))
@@ -138,7 +142,7 @@ class ζ(PATTERN):
138
142
  if callable(self.N): self.P = self.N()
139
143
  else: self.P = _globals[str(self.N)]
140
144
  else: self.P = _globals[self.N]
141
- yield from self.P
145
+ yield from copy.deepcopy(self.P)
142
146
  #----------------------------------------------------------------------------------------------------------------------
143
147
  class nPush(PATTERN):
144
148
  def __init__(self): super().__init__()
@@ -341,15 +345,15 @@ class σ(PATTERN): # sigma, σ, sequence of characters, string patttern
341
345
  self.lit = self.s
342
346
  if not isinstance(self.lit, str):
343
347
  if callable(self.lit): self.lit = str(self.lit())
344
- else: self.lit = str(self.lit) # should possibly be exception
348
+ else: self.lit = str(self.lit) # might need to raise an exception
345
349
  logger.debug("σ(%r) trying(%d)", self.lit, pos0)
346
350
  if pos0 + len(self.lit) <= len(Ϣ[-1].subject):
347
351
  if self.lit == Ϣ[-1].subject[pos0:pos0 + len(self.lit)]:
348
352
  logger.info("σ(%r) SUCCESS(%d,%d)=", self.lit, Ϣ[-1].pos, len(self.lit))
349
353
  Ϣ[-1].pos += len(self.lit)
350
354
  yield slice(pos0, Ϣ[-1].pos)
351
- Ϣ[-1].pos -= len(self.lit)
352
- logger.warning("σ(%r) backtracking(%d)...", self.lit, Ϣ[-1].pos)
355
+ logger.warning("σ(%r) backtracking(%d,%d)...", self.lit, pos0, Ϣ[-1].pos)
356
+ Ϣ[-1].pos = pos0
353
357
  return None
354
358
  #----------------------------------------------------------------------------------------------------------------------
355
359
  class ANY(PATTERN):
@@ -370,8 +374,8 @@ class ANY(PATTERN):
370
374
  logger.info("ANY(%r) SUCCESS(%d,%d)=%s", self.characters, Ϣ[-1].pos, 1, Ϣ[-1].subject[Ϣ[-1].pos])
371
375
  Ϣ[-1].pos += 1
372
376
  yield slice(Ϣ[-1].pos - 1, Ϣ[-1].pos)
377
+ logger.warning("ANY(%r) backtracking(%d,%d)...", self.characters, Ϣ[-1].pos - 1, Ϣ[-1].pos)
373
378
  Ϣ[-1].pos -= 1
374
- logger.warning("ANY(%r) backtracking(%d)...", self.characters, Ϣ[-1].pos)
375
379
  #----------------------------------------------------------------------------------------------------------------------
376
380
  class NOTANY(PATTERN):
377
381
  def __init__(self, chars): super().__init__(); self.chars = chars
@@ -391,8 +395,8 @@ class NOTANY(PATTERN):
391
395
  logger.info("NOTANY(%r) SUCCESS(%d,%d)=%s", self.characters, Ϣ[-1].pos, 1, Ϣ[-1].subject[Ϣ[-1].pos])
392
396
  Ϣ[-1].pos += 1
393
397
  yield slice(Ϣ[-1].pos - 1, Ϣ[-1].pos)
398
+ logger.warning("NOTANY(%r) backtracking(%d,%d)...", self.characters, Ϣ[-1].pos - 1, Ϣ[-1].pos)
394
399
  Ϣ[-1].pos -= 1
395
- logger.warning("NOTANY(%r) backtracking(%d)...", self.characters, Ϣ[-1].pos)
396
400
  #----------------------------------------------------------------------------------------------------------------------
397
401
  class SPAN(PATTERN):
398
402
  def __init__(self, chars): super().__init__(); self.chars = chars
@@ -415,8 +419,8 @@ class SPAN(PATTERN):
415
419
  if Ϣ[-1].pos > pos0:
416
420
  logger.info("SPAN(%r) SUCCESS(%d,%d)=%s", self.characters, pos0, Ϣ[-1].pos - pos0, Ϣ[-1].subject[pos0:Ϣ[-1].pos])
417
421
  yield slice(pos0, Ϣ[-1].pos)
422
+ logger.warning("SPAN(%r) backtracking(%d,%d)...", self.characters, pos0, Ϣ[-1].pos)
418
423
  Ϣ[-1].pos = pos0
419
- logger.warning("SPAN(%r) backtracking(%d)...", self.characters, Ϣ[-1].pos)
420
424
  return None
421
425
  #----------------------------------------------------------------------------------------------------------------------
422
426
  class BREAK(PATTERN):
@@ -440,8 +444,8 @@ class BREAK(PATTERN):
440
444
  if Ϣ[-1].pos < len(Ϣ[-1].subject):
441
445
  logger.info("BREAK(%r) SUCCESS(%d,%d)=%s", self.characters, pos0, Ϣ[-1].pos - pos0, Ϣ[-1].subject[pos0:Ϣ[-1].pos])
442
446
  yield slice(pos0, Ϣ[-1].pos)
447
+ logger.warning("BREAK(%r) backtracking(%d,%d)...", self.characters, pos0, Ϣ[-1].pos)
443
448
  Ϣ[-1].pos = pos0
444
- logger.warning("BREAK(%r) backtracking(%d)...", self.characters, Ϣ[-1].pos)
445
449
  #----------------------------------------------------------------------------------------------------------------------
446
450
  class BREAKX(BREAK): pass
447
451
  #----------------------------------------------------------------------------------------------------------------------
@@ -621,7 +625,7 @@ class φ(PATTERN):
621
625
  Ϣ[-1].pos = pos0
622
626
  else: raise Exception("Yikes! Internal error.")
623
627
  #----------------------------------------------------------------------------------------------------------------------
624
- class ρ(PATTERN): # PSI, AND, conjunction
628
+ class ρ(PATTERN): # rho, AND, conjunction
625
629
  def __init__(self, P:PATTERN, Q:PATTERN): super().__init__(); self.P = P; self.Q = Q
626
630
  def __repr__(self): return "ρ(*{0})".format(len(self.AP))
627
631
  def __deepcopy__(self, memo): return ρ(copy.deepcopy(self.P), copy.deepcopy(self.Q))
@@ -674,7 +678,7 @@ class Σ(PATTERN): # SIGMA, Σ, sequence, subsequents, SNOBOL4: P Q R S T ...
674
678
  if cursor >= len(self.AP):
675
679
  logger.info("Σ(*) SUCCESS(%d,%d)=%s", pos0, Ϣ[-1].pos - pos0, Ϣ[-1].subject[pos0:Ϣ[-1].pos])
676
680
  yield slice(pos0, Ϣ[-1].pos)
677
- logger.warning("Σ(*) backtracking(%d)...", pos0)
681
+ logger.warning("Σ(*) backtracking(%d,%d)...", pos0, Ϣ[-1].pos)
678
682
  cursor -= 1
679
683
  if cursor >= highmark:
680
684
  iter(self.AP[cursor])
@@ -746,7 +750,7 @@ class DEBUG_formatter(logging.Formatter):
746
750
  global Ϣ, _window_size
747
751
  original_message = super().format(record)
748
752
  if len(Ϣ) > 0:
749
- formatted_message = "{0:s} {1:s}".format(self.window(_window_size // 2), original_message) # , ' ' * Ϣ[-1].depth
753
+ formatted_message = "{0:s} {1:s}".format(self.window(_window_size // 2), original_message) # {2:s} # ' ' * Ϣ[-1].depth,
750
754
  else: formatted_message = original_message
751
755
  return formatted_message
752
756
  #----------------------------------------------------------------------------------------------------------------------
@@ -842,10 +846,14 @@ if __name__ == "__main__":
842
846
  from SNOBOL4functions import DEFINE, REPLACE, SUBSTITUTE
843
847
  from SNOBOL4functions import END, RETURN, FRETURN, NRETURN
844
848
  GLOBALS(globals())
849
+ TRACE(50)
850
+ # --------------------------------------------------------------------------------------------------------------------
845
851
  if "SNOBOL4" in POS(0) + (SPAN("ABCDEFGHIJKLMNOPQRSTUVWXYZ") + σ('4')) % "name" + RPOS(0):
846
852
  print(name)
847
853
  if "SNOBOL4" in POS(0) + (BREAK("0123456789") + σ('4')) % "name" + RPOS(0):
848
854
  print(name)
849
855
  if "001_01C717AB.5C51AFDE ..." in φ(r"(?P<name>[0-9]{3}(_[0-9A-F]{4})?_[0-9A-F]{8}\.[0-9A-F]{8})"):
850
856
  print(name)
857
+ # --------------------------------------------------------------------------------------------------------------------
858
+ exit(0)
851
859
  #-----------------------------------------------------------------------------------------------------------------------
@@ -0,0 +1,104 @@
1
+ ' '| 0|'(x*y) ' Σ(Θ('pos') Λ(<function <lambda> at 0x00000197996a1ec0>) POS(0) Π(*3) Θ('pos') Λ(<function <lambda> at 0x00000197996a1f60>) RPOS(0)) trying(0)...
2
+ ' '| 0|'(x*y) ' Θ(pos) SUCCESS
3
+ ' '| 0|'(x*y) ' Λ(function) evaluating...
4
+ ' '| 0|'(x*y) ' Λ(function) SUCCESS
5
+ ' '| 0|'(x*y) ' POS(0) SUCCESS(0,0)=
6
+ ' '| 0|'(x*y) ' Π(Σ(*3) Σ(*2) Π(*3)) trying(0)...
7
+ ' '| 0|'(x*y) ' Σ(Π(*3) ANY('+-*/') ζ('X')) trying(0)...
8
+ ' '| 0|'(x*y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(0)...
9
+ ' '| 0|'(x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(0)
10
+ ' '| 0|'(x*y) ' SPAN('0123456789') trying(0)
11
+ ' '| 0|'(x*y) ' Σ(σ('(') ζ('X') σ(')')) trying(0)...
12
+ ' '| 0|'(x*y) ' σ('(') trying(0)
13
+ ' '| 0|'(x*y) ' σ('(') SUCCESS(0,1)=
14
+ ' ('| 1|'x*y) ' Π(Σ(*3) Σ(*2) Π(*3)) trying(1)...
15
+ ' ('| 1|'x*y) ' Σ(Π(*3) ANY('+-*/') ζ('X')) trying(1)...
16
+ ' ('| 1|'x*y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(1)...
17
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(1)
18
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(1,1)=x
19
+ ' (x'| 2|'*y) ' ANY('+-*/') trying(2)
20
+ ' (x'| 2|'*y) ' ANY('+-*/') SUCCESS(2,1)=*
21
+ ' (x*'| 3|'y) ' Π(Σ(*3) Σ(*2) Π(*3)) trying(3)...
22
+ ' (x*'| 3|'y) ' Σ(Π(*3) ANY('+-*/') ζ('X')) trying(3)...
23
+ ' (x*'| 3|'y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(3)...
24
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(3)
25
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(3,1)=y
26
+ ' (x*y'| 4|') ' ANY('+-*/') trying(4)
27
+ ' (x*y'| 4|') ' ANY('abcdefghijklmnopqrstuvwxyz') backtracking(3,4)...
28
+ ' (x*'| 3|'y) ' SPAN('0123456789') trying(3)
29
+ ' (x*'| 3|'y) ' Σ(σ('(') ζ('X') σ(')')) trying(3)...
30
+ ' (x*'| 3|'y) ' σ('(') trying(3)
31
+ ' (x*'| 3|'y) ' Σ(ANY('+-') ζ('X')) trying(3)...
32
+ ' (x*'| 3|'y) ' ANY('+-') trying(3)
33
+ ' (x*'| 3|'y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(3)...
34
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(3)
35
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(3,1)=y
36
+ ' (x*y'| 4|') ' Σ(*) SUCCESS(1,3)=x*y
37
+ ' (x*y'| 4|') ' σ(')') trying(4)
38
+ ' (x*y'| 4|') ' σ(')') SUCCESS(4,1)=
39
+ ' (x*y)'| 5|' ' Σ(*) SUCCESS(0,5)=(x*y)
40
+ ' (x*y)'| 5|' ' ANY('+-*/') trying(5)
41
+ ' (x*y)'| 5|' ' Σ(*) backtracking(0, 5)...
42
+ ' (x*y'| 4|') ' σ(')') backtracking(4)...
43
+ ' (x*y'| 4|') ' Σ(*) backtracking(1, 4)...
44
+ ' (x*y'| 4|') ' ANY('abcdefghijklmnopqrstuvwxyz') backtracking(3,4)...
45
+ ' (x*'| 3|'y) ' SPAN('0123456789') trying(3)
46
+ ' (x*'| 3|'y) ' Σ(σ('(') ζ('X') σ(')')) trying(3)...
47
+ ' (x*'| 3|'y) ' σ('(') trying(3)
48
+ ' (x*'| 3|'y) ' ANY('+-*/') backtracking(2,3)...
49
+ ' (x'| 2|'*y) ' ANY('abcdefghijklmnopqrstuvwxyz') backtracking(1,2)...
50
+ ' ('| 1|'x*y) ' SPAN('0123456789') trying(1)
51
+ ' ('| 1|'x*y) ' Σ(σ('(') ζ('X') σ(')')) trying(1)...
52
+ ' ('| 1|'x*y) ' σ('(') trying(1)
53
+ ' ('| 1|'x*y) ' Σ(ANY('+-') ζ('X')) trying(1)...
54
+ ' ('| 1|'x*y) ' ANY('+-') trying(1)
55
+ ' ('| 1|'x*y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(1)...
56
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(1)
57
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(1,1)=x
58
+ ' (x'| 2|'*y) ' σ(')') trying(2)
59
+ ' (x'| 2|'*y) ' ANY('abcdefghijklmnopqrstuvwxyz') backtracking(1,2)...
60
+ ' ('| 1|'x*y) ' SPAN('0123456789') trying(1)
61
+ ' ('| 1|'x*y) ' Σ(σ('(') ζ('X') σ(')')) trying(1)...
62
+ ' ('| 1|'x*y) ' σ('(') trying(1)
63
+ ' '| 0|'(x*y) ' σ('(') backtracking(0)...
64
+ ' '| 0|'(x*y) ' Σ(ANY('+-') ζ('X')) trying(0)...
65
+ ' '| 0|'(x*y) ' ANY('+-') trying(0)
66
+ ' '| 0|'(x*y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(0)...
67
+ ' '| 0|'(x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(0)
68
+ ' '| 0|'(x*y) ' SPAN('0123456789') trying(0)
69
+ ' '| 0|'(x*y) ' Σ(σ('(') ζ('X') σ(')')) trying(0)...
70
+ ' '| 0|'(x*y) ' σ('(') trying(0)
71
+ ' '| 0|'(x*y) ' σ('(') SUCCESS(0,1)=
72
+ ' ('| 1|'x*y) ' Π(Σ(*3) Σ(*2) Π(*3)) trying(1)...
73
+ ' ('| 1|'x*y) ' Σ(Π(*3) ANY('+-*/') ζ('X')) trying(1)...
74
+ ' ('| 1|'x*y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(1)...
75
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(1)
76
+ ' ('| 1|'x*y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(1,1)=x
77
+ ' (x'| 2|'*y) ' ANY('+-*/') trying(2)
78
+ ' (x'| 2|'*y) ' ANY('+-*/') SUCCESS(2,1)=*
79
+ ' (x*'| 3|'y) ' Π(Σ(*3) Σ(*2) Π(*3)) trying(3)...
80
+ ' (x*'| 3|'y) ' Σ(Π(*3) ANY('+-*/') ζ('X')) trying(3)...
81
+ ' (x*'| 3|'y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(3)...
82
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(3)
83
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(3,1)=y
84
+ ' (x*y'| 4|') ' ANY('+-*/') trying(4)
85
+ ' (x*y'| 4|') ' ANY('abcdefghijklmnopqrstuvwxyz') backtracking(3,4)...
86
+ ' (x*'| 3|'y) ' SPAN('0123456789') trying(3)
87
+ ' (x*'| 3|'y) ' Σ(σ('(') ζ('X') σ(')')) trying(3)...
88
+ ' (x*'| 3|'y) ' σ('(') trying(3)
89
+ ' (x*'| 3|'y) ' Σ(ANY('+-') ζ('X')) trying(3)...
90
+ ' (x*'| 3|'y) ' ANY('+-') trying(3)
91
+ ' (x*'| 3|'y) ' Π(ANY('abcdefghijklmnopqrstuvwxyz') SPAN('0123456789') Σ(*3)) trying(3)...
92
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') trying(3)
93
+ ' (x*'| 3|'y) ' ANY('abcdefghijklmnopqrstuvwxyz') SUCCESS(3,1)=y
94
+ ' (x*y'| 4|') ' Σ(*) SUCCESS(1,3)=x*y
95
+ ' (x*y'| 4|') ' σ(')') trying(4)
96
+ ' (x*y'| 4|') ' σ(')') SUCCESS(4,1)=
97
+ ' (x*y)'| 5|' ' Σ(*) SUCCESS(0,5)=(x*y)
98
+ ' (x*y)'| 5|' ' Θ(pos) SUCCESS
99
+ ' (x*y)'| 5|' ' Λ(function) evaluating...
100
+ ' (x*y)'| 5|' ' Λ(function) SUCCESS
101
+ ' (x*y)'| 5|' ' RPOS(0) SUCCESS(5,0)=
102
+ ' (x*y)'| 5|' ' Σ(*) SUCCESS(0,5)=(x*y)
103
+ ' (x*y)'| 5|' ' SEARCH(): "(x*y)" ? "slice(0, 5, None)"
104
+ P0·R5·
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ requirements.txt
6
+ setup.cfg
7
+ src/SNOBOL4python/SNOBOL4functions.py
8
+ src/SNOBOL4python/SNOBOL4patterns.py
9
+ src/SNOBOL4python/__init__.py
10
+ src/SNOBOL4python/deleteme.py
11
+ tests/test_01.py
12
+ tests/test_arbno.py
13
+ tests/test_json.py
14
+ tests/test_re_simple.py
@@ -1,19 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: SNOBOL4python
3
- Version: 0.4.3
4
- Summary: A Python library for SNOBOL4-style pattern matching with regular expressions
5
- Author-email: Lon Jones Cherryholmes <lcherryh@yahoo.com>
6
- License-Expression: GPL-3.0-or-later
7
- Project-URL: Homepage, https://github.com/LCherryholmes/SNOBOL4python
8
- Project-URL: Repository, https://github.com/LCherryholmes/SNOBOL4python
9
- Project-URL: Issues, https://github.com/LCherryholmes/SNOBOL4python/issues
10
- Keywords: python,SNOBOL,SNOBOL4,string pattern matching
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.10.0
13
- Description-Content-Type: text/markdown
14
- License-File: LICENSE
15
- Dynamic: license-file
16
-
17
- # SNOBOL4python
18
-
19
- SNOBOL4python is a Python library for performing SNOBOL4-style pattern matching.
@@ -1,18 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- setup.cfg
5
- src/SNOBOL4python/SNOBOL4functions.py
6
- src/SNOBOL4python/SNOBOL4patterns.py
7
- src/SNOBOL4python/__init__.py
8
- src/SNOBOL4python.egg-info/PKG-INFO
9
- src/SNOBOL4python.egg-info/SOURCES.txt
10
- src/SNOBOL4python.egg-info/dependency_links.txt
11
- src/SNOBOL4python.egg-info/top_level.txt
12
- tests/test_01.py
13
- tests/test_arbno.py
14
- tests/test_icon-1.py
15
- tests/test_icon-2.py
16
- tests/test_icon-3.py
17
- tests/test_json.py
18
- tests/test_re_simple.py
@@ -1 +0,0 @@
1
- SNOBOL4python
@@ -1,152 +0,0 @@
1
- import timeit
2
- #------------------------------------------------------------------------------
3
- def report(s=""): pass # print(s)
4
- #==============================================================================
5
- # ICON Programming Language: (1st pass, attribute grammar generated)
6
- #
7
- # every write(5 > ((1 to 2) * (3 to 4)));
8
- #==============================================================================
9
- def x5(port):
10
- global x5_V
11
- match port:
12
- case "start": x5_V = 5; x5("succeed")
13
- case "resume": x5("fail")
14
- case "fail": greater("fail")
15
- case "succeed": mult("start")
16
- #------------------------------------------------------------------------------
17
- def x1(port):
18
- global x1_V
19
- match port:
20
- case "start": x1_V = 1; x1("succeed")
21
- case "resume": x1("fail")
22
- case "fail": to1("fail")
23
- case "succeed": x2("start")
24
- #------------------------------------------------------------------------------
25
- def x2(port):
26
- global x2_V, to1_I, x1_V
27
- match port:
28
- case "start": x2_V = 2; x2("succeed")
29
- case "resume": x2("fail")
30
- case "fail": x1("resume")
31
- case "succeed": to1_I = x1_V; to1("code")
32
- #------------------------------------------------------------------------------
33
- def to1(port):
34
- global to1_V, to1_I, x2_V
35
- match port:
36
- case "start": x1("start")
37
- case "resume": to1_I = to1_I + 1; to1("code")
38
- case "code": #
39
- if to1_I <= x2_V:
40
- to1_V = to1_I; to1("succeed")
41
- else: x2("resume")
42
- case "fail": mult("fail")
43
- case "succeed": to2("start")
44
- #------------------------------------------------------------------------------
45
- def x3(port):
46
- global x3_V
47
- match port:
48
- case "start": x3_V = 3; x3("succeed")
49
- case "resume": x3("fail")
50
- case "fail": to2("fail")
51
- case "succeed": x4("start")
52
- #------------------------------------------------------------------------------
53
- def x4(port):
54
- global x4_V, to2_I, x3_V
55
- match port:
56
- case "start": x4_V = 4; x4("succeed")
57
- case "resume": x4("fail")
58
- case "fail": x3("resume")
59
- case "succeed": to2_I = x3_V; to2("code")
60
- #------------------------------------------------------------------------------
61
- def to2(port):
62
- global to2_V, to2_I, x4_V, mult_V, to1_V
63
- match port:
64
- case "start": x3("start")
65
- case "resume": to2_I = to2_I + 1; to2("code")
66
- case "code": #
67
- if to2_I <= x4_V:
68
- to2_V = to2_I; to2("succeed")
69
- else: x4("resume")
70
- case "fail": to1("resume")
71
- case "succeed": mult_V = to1_V * to2_V; mult("succeed")
72
- #------------------------------------------------------------------------------
73
- def mult(port):
74
- global mult_V, x5_V, greater_V
75
- match port:
76
- case "start": to1("start")
77
- case "resume": to2("resume")
78
- case "fail": x5("resume")
79
- case "succeed": #
80
- if x5_V <= mult_V: mult("resume")
81
- else: greater_V = mult_V; greater("succeed")
82
- #------------------------------------------------------------------------------
83
- def greater(port):
84
- global greater_V, write1_V
85
- match port:
86
- case "start": x5("start")
87
- case "resume": mult("resume")
88
- case "fail": write1("fail")
89
- case "succeed": write1_V = greater_V; report(write1_V); write1("succeed")
90
- #------------------------------------------------------------------------------
91
- def write1(port):
92
- match port:
93
- case "start": greater("start")
94
- case "resume": greater("resume")
95
- case "fail": report("Failure.") # Yeah! UNWIND already.
96
- case "succeed": report("Success!"); write1("resume")
97
- #==============================================================================
98
- # ICON Programming Language: (2nd pass, optimization)
99
- #
100
- # every write(5 > ((1 to 2) * (3 to 4)));
101
- def write2(port):
102
- global to3_I, to4_I
103
- while True:
104
- match port:
105
- case "start": to3_I = 1; to3("code"); break
106
- case "resume": to4_I = to4_I + 1; to4("code"); break
107
- case "fail": report("Failure."); break # Yeah! UNWIND already.
108
- case "succeed": #
109
- report("Success!")
110
- port = "resume" # loop
111
- case _: raise Exception()
112
- #------------------------------------------------------------------------------
113
- def to3(port):
114
- global to3_I, to4_I
115
- while True:
116
- match port:
117
- case "resume": to3_I = to3_I + 1; port = "code"
118
- case "code": #
119
- if to3_I > 2: write2("fail")
120
- else: to4_I = 3; to4("code")
121
- break
122
- case _: raise Exception()
123
- #------------------------------------------------------------------------------
124
- def to4(port):
125
- global to4_I, mult_V, to3_I, greater_V
126
- while True:
127
- match port:
128
- case "code": #
129
- if to4_I > 4: to3("resume"); break
130
- else: mult_V = to3_I * to4_I
131
- if 5 <= mult_V: write2("resume"); break
132
- else: greater_V = mult_V
133
- report(greater_V)
134
- write2("succeed")
135
- break
136
- case _: raise Exception()
137
- #==============================================================================
138
- def main():
139
- if True:
140
- time1 = timeit.timeit(lambda: write1("start"), number = 1_000_000, globals = globals());
141
- print(time1)
142
- time2 = timeit.timeit(lambda: write2("start"), number = 1_000_000, globals = globals());
143
- print(time2)
144
- else:
145
- report()
146
- write1("start")
147
- report()
148
- write2("start")
149
- #------------------------------------------------------------------------------
150
- if __name__ == '__main__':
151
- main()
152
- #------------------------------------------------------------------------------
@@ -1,115 +0,0 @@
1
- import timeit
2
- #------------------------------------------------------------------------------
3
- def report(s=""): pass # print(s)
4
- #-----------------------------------------------------------------------------------
5
- # ICON Programming Language: (1st pass, attribute grammar generated)
6
- #
7
- # every write(5 > ((1 to 2) * (3 to 4)));
8
- #-----------------------------------------------------------------------------------
9
- def x5_start(): global x5_V; x5_V = 5; x5_succeed()
10
- def x5_resume(): x5_fail()
11
- #-----------------------------------------------------------------------------------
12
- def x1_start(): global x1_V; x1_V = 1; x1_succeed()
13
- def x1_resume(): x1_fail()
14
- #-----------------------------------------------------------------------------------
15
- def x2_start(): global x2_V; x2_V = 2; x2_succeed()
16
- def x2_resume(): x2_fail()
17
- #-----------------------------------------------------------------------------------
18
- def to1_start(): x1_start()
19
- def x1_fail(): to1_fail()
20
- def x2_fail(): x1_resume()
21
- def to1_code():
22
- global to1_I, x2_V, to1_V
23
- if to1_I > x2_V: x2_resume()
24
- else: to1_V = to1_I; to1_succeed()
25
- def to1_resume(): global to1_I; to1_I = to1_I + 1; to1_code()
26
- def x1_succeed(): x2_start()
27
- def x2_succeed(): global to1_I, x1_V; to1_I = x1_V; to1_code()
28
- #-----------------------------------------------------------------------------------
29
- def x3_start(): global x3_V; x3_V = 3; x3_succeed()
30
- def x3_resume(): x3_fail()
31
- #-----------------------------------------------------------------------------------
32
- def x4_start(): global x4_V; x4_V = 4; x4_succeed()
33
- def x4_resume(): x4_fail()
34
- #-----------------------------------------------------------------------------------
35
- def to2_start(): x3_start()
36
- def x3_fail(): to2_fail()
37
- def x4_fail(): x3_resume()
38
- def to2_code():
39
- global to2_I, x4_V, to2_V
40
- if to2_I > x4_V: x4_resume()
41
- else: to2_V = to2_I; to2_succeed()
42
- def to2_resume(): global to2_I; to2_I = to2_I + 1; to2_code()
43
- def x3_succeed(): x4_start()
44
- def x4_succeed(): global to2_I, x3_V; to2_I = x3_V; to2_code()
45
- #-----------------------------------------------------------------------------------
46
- def mult_start(): to1_start()
47
- def to1_fail(): mult_fail()
48
- def to2_fail(): to1_resume()
49
- def mult_resume(): to2_resume()
50
- def to1_succeed(): to2_start()
51
- def to2_succeed():
52
- global mult_V, to1_V, to2_V
53
- mult_V = to1_V * to2_V; mult_succeed()
54
- #-----------------------------------------------------------------------------------
55
- def greater_start(): x5_start()
56
- def x5_fail(): greater_fail()
57
- def mult_fail(): x5_resume()
58
- def greater_resume(): mult_resume()
59
- def x5_succeed(): mult_start()
60
- def mult_succeed():
61
- global x5_V, mult_V, greater_V
62
- if x5_V <= mult_V: mult_resume()
63
- else: greater_V = mult_V; greater_succeed()
64
- #-----------------------------------------------------------------------------------
65
- def write1_start(): greater_start()
66
- def write1_resume(): greater_resume()
67
- def greater_fail(): write1_fail()
68
- def greater_succeed():
69
- global write_V, greater_V
70
- write_V = greater_V
71
- report(write_V); write1_succeed()
72
- #-----------------------------------------------------------------------------------
73
- # ICON Programming Language: (2nd pass, optimization)
74
- #
75
- # every write(5 > ((1 to 2) * (3 to 4)));
76
- #-----------------------------------------------------------------------------------
77
- def write2_start(): global to3_I; to3_I = 1; to3_code()
78
- def to3_resume(): global to3_I; to3_I = to3_I + 1; to3_code()
79
- def to3_code():
80
- global to3_I, to4_I
81
- if to3_I > 2: write2_fail()
82
- else: to4_I = 3; to4_code()
83
- def write2_resume(): global to4_I; to4_I = to4_I + 1; to4_code()
84
- def to4_code():
85
- global to4_I, mult_V, to3_I, greater_V
86
- if to4_I > 4: to3_resume()
87
- else:
88
- mult_V = to3_I * to4_I
89
- if 5 <= mult_V: write2_resume()
90
- else:
91
- greater_V = mult_V
92
- report(greater_V); write2_succeed()
93
- #-----------------------------------------------------------------------------------
94
- def icon1(): write1_start()
95
- def write1_fail(): report("Failure.") # Yeah! UNWIND already.
96
- def write1_succeed(): report("Success!"); write1_resume()
97
- def icon2(): write2_start()
98
- def write2_fail(): report("Failure.") # Yeah! UNWIND already.
99
- def write2_succeed(): report("Success!"); write2_resume()
100
- #-----------------------------------------------------------------------------------
101
- def main():
102
- if True:
103
- time1 = timeit.timeit(lambda: icon1(), number = 1_000_000, globals = globals());
104
- print(time1)
105
- time2 = timeit.timeit(lambda: icon2(), number = 1_000_000, globals = globals());
106
- print(time2)
107
- else:
108
- report()
109
- icon1()
110
- report()
111
- icon2()
112
- #-----------------------------------------------------------------------------------
113
- if __name__ == '__main__':
114
- main()
115
- #-----------------------------------------------------------------------------------
@@ -1,29 +0,0 @@
1
- import timeit
2
- import pyopencl as cl
3
- import numpy as np
4
- #------------------------------------------------------------------------------
5
- ctx = cl.create_some_context()
6
- queue = cl.CommandQueue(ctx)
7
- input_text = "\0" * 1024
8
- input_array = np.frombuffer(input_text.encode('ascii'), dtype=np.uint8)
9
- mf = cl.mem_flags
10
- input_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=input_array)
11
- output_buf = cl.Buffer(ctx, mf.WRITE_ONLY, input_array.nbytes)
12
- #------------------------------------------------------------------------------
13
- c_name = "C:/SNOBOL4python/tests/test_icon.c"
14
- with open(c_name, "r") as c_file:
15
- kernel_source = c_file.read()
16
- program = cl.Program(ctx, kernel_source).build()
17
- global_size = (1,) # (input_array.size,)
18
- if True:
19
- time = timeit.timeit(
20
- lambda: program.icon(queue, global_size, None, input_buf, output_buf, np.uint32(input_array.size))
21
- , number = 100_000, globals = globals());
22
- print(time)
23
- else: program.icon(queue, global_size, None, input_buf, output_buf, np.uint32(input_array.size))
24
- output_array = np.empty_like(input_array)
25
- cl.enqueue_copy(queue, output_array, output_buf)
26
- queue.finish()
27
- output_text = output_array.tobytes().decode('ascii')
28
- print(output_text)
29
- #------------------------------------------------------------------------------
File without changes
File without changes
File without changes