Forever-Young / mrab-regex-hg

Automatically exported from code.google.com/p/mrab-regex-hg
0 stars 0 forks source link

ply package unit tests fail with re replaced by regex #81

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Download the ply sources, git://github.com/dabeaz/ply.git
2. Replace "import re" with "import regex as re" in ply/lex.py and yacc.py
3. In test, run python testlex.py

What is the expected output? What do you see instead?
Expected is no errors, instead we get
FAIL: test_lex_re1 (__main__.LexErrorWarningTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "testlex.py", line 143, in test_lex_re1
    "Invalid regular expression for rule 't_NUMBER'. unbalanced parenthesis\n"))
AssertionError: False is not true

======================================================================
FAIL: test_lex_re3 (__main__.LexErrorWarningTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "testlex.py", line 155, in test_lex_re3
    "Invalid regular expression for rule 't_POUND'. unbalanced parenthesis\n"
AssertionError: False is not true

What version of the product are you using? On what operating system?
Macports reports version 0.1.20121008_0 (python 2.7.3)

Please provide any additional information below.

Original issue reported on code.google.com by greger.c...@gmail.com on 18 Oct 2012 at 6:25

GoogleCodeExporter commented 9 years ago
I'm not familiar with that package.

What is the regex that it's using? What is the string that it's trying to match?

Original comment by re...@mrabarnett.plus.com on 18 Oct 2012 at 3:03

GoogleCodeExporter commented 9 years ago
ply is a yacc/lex implementation in pure python that I wanted to try and speed 
up using regex instead of the regular re (with concurrency). The regular 
expressions are constructed from a user defined token/grammar definition so 
it's not trivial to figure out in the general case.

In this case I guess it should be possible, but I don't know the exact string 
that's passed to re(gex).compile(). I might have time to track it down in the 
coming days.

Original comment by greger.c...@gmail.com on 18 Oct 2012 at 3:09

GoogleCodeExporter commented 9 years ago
It looks like the problem is that the re module raises re.error("unbalanced 
parenthesis") whereas the regex module raises regex.error("missing )").

I'm not sure what the proper solution is, whether to make regex's message match 
that of re, or just warn that you shouldn't rely on the phrasing of messages to 
detect what kind of error occurred!

Original comment by re...@mrabarnett.plus.com on 18 Oct 2012 at 3:19

GoogleCodeExporter commented 9 years ago
Ah, good!

I suggest the latter; close this issue and I'll open one in ply :-)

Thanks!

Original comment by greger.c...@gmail.com on 18 Oct 2012 at 3:21

GoogleCodeExporter commented 9 years ago

Original comment by re...@mrabarnett.plus.com on 25 Oct 2012 at 12:48