Skip to content

Pygments backend is generating regex with unescaped symbol  #477

Closed

Description

@praduca

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.

Activity

  1. andreasabel commented on Mar 20, 2024

    @andreasabel
    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.

  2. praduca commented on Mar 30, 2024

    @praduca
    Author

    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             
    
  3. added this to the 2.9.7 milestone on Oct 20, 2025
  4. added
    Pygments
    on Oct 20, 2025
  5. katrinafyi commented on Feb 23, 2026

    @katrinafyi
    Contributor

    Also has the same problem with $

  6. modified the milestones: 2.9.7, 2.9.6.3 on Mar 13, 2026
  7. Commelina commented on Mar 13, 2026

    @Commelina
    Member

    Fixed by #547.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pygmentsbug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions