Commit c3d93ad
Fix ASN.1 lexer: recognize minus sign and fix range operator (#3060)
Two fixes for the ASN.1 lexer:
1. Add `-` to the operator pattern so negative values in constraints
like `(-50..150)` are tokenized correctly instead of producing an
error token for the minus sign.
2. Require at least one digit after the decimal point in float literals
(`\d+\.\d+` instead of `\d+\.\d*`). This prevents `50..150` from
being incorrectly tokenized as float `50.` + punctuation `.` + int
`150`, instead of the correct int `50` + range `..` + int `150`.
Fixes #3014.
Co-authored-by: h1whelan <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>1 parent 4f06bcf commit c3d93ad
3 files changed
Lines changed: 73 additions & 54 deletions
File tree
- pygments/lexers
- tests
- examplefiles/asn1
- snippets/asn1
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments