Skip to content

Commit

Permalink
Merge unneeded state with it's parent rule
Browse files Browse the repository at this point in the history
The `blockname` state did not have a `#pop` after it's only rule,
which caused outputting errors in pygments#2094.

Instead of adding a `#pop`, I merged the `blockname` state with the
rule that uses it, to achieve the exact same lexing logic, but without
another state in the lexer.
  • Loading branch information
amitkummer committed Mar 27, 2022
1 parent 96eaeba commit b5f0c88
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions pygments/lexers/configs.py
Expand Up @@ -715,20 +715,15 @@ def heredoc_callback(self, match, ctx):

# e.g. resource "aws_security_group" "allow_tls" {
# e.g. backend "consul" {
(classes_re + r'(\s+)', bygroups(Keyword.Reserved, Whitespace), 'blockname'),
(classes_re + r'(\s+)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)',
bygroups(Keyword.Reserved, Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation)),

# here-doc style delimited strings
(
r'(<<-?)\s*([a-zA-Z_]\w*)(.*?\n)',
heredoc_callback,
)
],
'blockname': [
# e.g. resource "aws_security_group" "allow_tls" {
# e.g. backend "consul" {
(r'(\s*)("[0-9a-zA-Z-_]+")?(\s*)("[0-9a-zA-Z-_]+")(\s+)(\{)',
bygroups(Whitespace, Name.Class, Whitespace, Name.Variable, Whitespace, Punctuation)),
],
'identifier': [
(r'\b(var\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)),
(r'\b([0-9a-zA-Z-_\[\]]+\.[0-9a-zA-Z-_\.\[\]]+)\b', bygroups(Name.Variable)),
Expand Down

0 comments on commit b5f0c88

Please sign in to comment.