Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re.compile() cannot identify operator "(?<" #254

Closed
xiaxinmeng opened this issue Mar 16, 2023 · 3 comments
Closed

re.compile() cannot identify operator "(?<" #254

xiaxinmeng opened this issue Mar 16, 2023 · 3 comments

Comments

@xiaxinmeng
Copy link

In the following example, re.compile fails to match "(?<"

test.py:

import re
p=re.compile('(?<!abc)(def)')
p.search('abcddef') 

Error message:

error: invalid perl operator: (?<

Raised from: std.re.compile:0
/home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/codon/codon-linux-x86_64/codon-deploy/lib/codon/stdlib/re.codon:104:9
Aborted (core dumped)

Reproduce:
'codon/codon-linux-x86_64/codon-deploy/bin/codon' run -release test.py

Behavior on CPython 3.10.8: work well
Environment:
codon: v0.15.5 on Feb 6
Ubuntu 18.04

@xiaxinmeng
Copy link
Author

"\" also fails. For example:

import re
match = re.compile('((a)|b\\2)*')

output:

error: invalid escape sequence: \2

Raised from: std.re.compile:0
/home/xxm/Desktop/IFuzzer/experiment_on_different_interpreter/codon/codon-linux-x86_64/codon-deploy/lib/codon/stdlib/re.codon:104:9
Aborted (core dumped)

@arshajii
Copy link
Contributor

This is because Codon uses Google's re2 under the hood for regular expressions, which is faster but has some limitations. What we want to do at some point is also incorporate Python's regex engine and choose at compile time whether to go with Python or re2 (since the regex is normally known at compile time anyway).

@inumanag
Copy link
Contributor

Merging into #608 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants