Error on a CFG
Opened this issue · 2 comments
oaltun commented
I am getting an error from the following code. I think this is a bug, because other rule sets seems to work.
g = CFG(
{"S", "A", "B"},
{"a", "b", "e"},
{
("S", "A"),
("A", "aA"),
("A", "Aa"),
("A", "B"),
("A", "e"),
("B", "aAb"),
("B", "bAa"),
("B", "abA"),
("B", "baA"),
("B", "Aba"),
("B", "Aab"),
("B", "bAaAaAb"),
},
"S",
"e",
)
g.cyk("a")
Error:
Traceback (most recent call last):
File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\main.py", line 72, in <module>
g.cyk("a")
File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\cfg.py", line 597, in cyk
self._cnf.chamsky()
File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\cfg.py", line 578, in chamsky
p2.add((new_vars[i], new_vars.pop(0) + new_vars[i + 1]))
IndexError: list index out of range
pip freeze:
pip freeze
backcall==0.2.0
billiard==3.6.4.0
black==22.3.0
blinker==1.4
certifi==2021.10.8
click==8.1.0
colorama==0.4.4
executing==0.8.3
iniconfig==1.1.1
mypy-extensions==0.4.3
numpy==1.22.4
passlib==1.7.4
pathspec==0.9.0
pickleshare==0.7.5
platformdirs==2.5.1
pure-eval==0.2.2
python-dateutil==2.8.2
python-dotenv==0.20.0
pytz==2022.1
rfc3986==1.5.0
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
tomli==2.0.1
traitlets==5.2.1.post0
typing_extensions==4.2.0
urllib3==1.26.9
vine==5.0.0
wcwidth==0.2.5
wrapt==1.14.1
Windows 10
python --version: Python 3.10.4
mahdavipanah commented
I am getting an error from the following code. I think this is a bug, because other rule sets seems to work.
g = CFG( {"S", "A", "B"}, {"a", "b", "e"}, { ("S", "A"), ("A", "aA"), ("A", "Aa"), ("A", "B"), ("A", "e"), ("B", "aAb"), ("B", "bAa"), ("B", "abA"), ("B", "baA"), ("B", "Aba"), ("B", "Aab"), ("B", "bAaAaAb"), }, "S", "e", ) g.cyk("a")
Error:
Traceback (most recent call last): File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\main.py", line 72, in <module> g.cyk("a") File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\cfg.py", line 597, in cyk self._cnf.chamsky() File "C:\Users\oguz\Documents\o\samsung\work\pyCFG\cfg.py", line 578, in chamsky p2.add((new_vars[i], new_vars.pop(0) + new_vars[i + 1])) IndexError: list index out of range
pip freeze:
pip freeze
backcall==0.2.0 billiard==3.6.4.0 black==22.3.0 blinker==1.4 certifi==2021.10.8 click==8.1.0 colorama==0.4.4 executing==0.8.3 iniconfig==1.1.1 mypy-extensions==0.4.3 numpy==1.22.4 passlib==1.7.4 pathspec==0.9.0 pickleshare==0.7.5 platformdirs==2.5.1 pure-eval==0.2.2 python-dateutil==2.8.2 python-dotenv==0.20.0 pytz==2022.1 rfc3986==1.5.0 six==1.16.0 sniffio==1.2.0 sortedcontainers==2.4.0 tomli==2.0.1 traitlets==5.2.1.post0 typing_extensions==4.2.0 urllib3==1.26.9 vine==5.0.0 wcwidth==0.2.5 wrapt==1.14.1
Windows 10 python --version: Python 3.10.4
It's either a bug or a situation that requires a specific validation. I am not currently maintaining this project but you are more than welcome to create a merge request for it.
oaltun commented
Just to document, it seems to have problems with long rules. Same error:
S ->aSbA | bSaA | bBaBaBb
A -> a | e
B -> aBb | bBa | e