Skip to content

Commit

Permalink
Improve CddlLexer performance (#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
blu-base committed Nov 16, 2021
1 parent d37c02b commit d9f2e6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 118 deletions.
5 changes: 3 additions & 2 deletions pygments/lexers/cddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class CddlLexer(RegexLexer):

_re_id = (
r"[$@A-Z_a-z]"
r"(?:[\-\.]*[$@0-9A-Z_a-z]|[$@0-9A-Z_a-z])*"
r"(?:[\-\.]+(?=[$@0-9A-Z_a-z])|[$@0-9A-Z_a-z])*"

)

# While the spec reads more like "an int must not start with 0" we use a
Expand Down Expand Up @@ -186,6 +187,6 @@ class CddlLexer(RegexLexer):
"bstr": [
(r"'", String.Single, "#pop"),
(r"\\.", String.Escape),
(r"[^']", String.Single),
(r"[^'\\]+", String.Single),
],
}
123 changes: 7 additions & 116 deletions tests/examplefiles/cddl/example.cddl.output

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9f2e6c

Please sign in to comment.