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

Pygments backend is generating regex with unescaped symbol #477

Open
praduca opened this issue Mar 19, 2024 · 2 comments
Open

Pygments backend is generating regex with unescaped symbol #477

praduca opened this issue Mar 19, 2024 · 2 comments

Comments

@praduca
Copy link

praduca commented Mar 19, 2024

I have a grammar (a basic language) that have ^ as an operator. The generated code for the operators on the pygments code include this symbol unescaped, and the generated highlighter is locking at 100% cpu usage because of this. Escaping the symbol solves the lock.

Other symbols are being correctly escaped, it appears that is only ^ that is not being escaped.

@andreasabel
Copy link
Member

Should ^ be added here then?

escape c | c `elem` (".'[]()|*+?{}\\" :: String) = ['\\',c]

We need a self-contained reproducer (that will go into the testsuite) if we want to fix this.

@praduca
Copy link
Author

praduca commented Mar 30, 2024

Can calc.cf be expanded and used? something like this

EAdd.      Exp  ::= Exp  "+" Exp1 ;
ESub.      Exp  ::= Exp  "-" Exp1 ;
EMul.      Exp1 ::= Exp1 "*" Exp2 ;
EDiv.      Exp1 ::= Exp1 "/" Exp2 ;
EPow.      Exp2 ::= Exp2 "^" Exp3; 
EInt.      Exp3 ::= Integer       ;
coercions  Exp  3             

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

2 participants