fix dbc multi-line comment lexing

This commit is contained in:
len0rd 2025-02-27 13:22:36 -05:00
parent f87f46701b
commit 430bc0172a

11
conf.py
View file

@ -72,8 +72,9 @@ class CanbusDbcLexer(RegexLexer):
tokens = { tokens = {
"root": [ "root": [
(r"[:\|\[\],\(\)]", token.Punctuation), (r"[:\|\[\],\(\);f]", token.Punctuation),
(r"[\@\-\+]", token.Operator), (r"[\@\-\+]", token.Operator),
(r'"[\S\s]*?"', token.String),
("CM_", token.Keyword, "comment"), ("CM_", token.Keyword, "comment"),
("SG_", token.Keyword, "signal"), ("SG_", token.Keyword, "signal"),
("BO_", token.Keyword, "msg"), ("BO_", token.Keyword, "msg"),
@ -133,19 +134,17 @@ class CanbusDbcLexer(RegexLexer):
], ],
"comment": [ "comment": [
( (
r'(\s+)(BO_)(\s+)(\d+)(\s+)(".*?")(;)', r'(\s+)(BO_)(\s+)(\d+)(\s+)',
bygroups( bygroups(
token.Whitespace, token.Whitespace,
token.Keyword, token.Keyword,
token.Whitespace, token.Whitespace,
token.Number, token.Number,
token.Whitespace, token.Whitespace,
token.String,
token.Punctuation,
), ),
), ),
( (
r'(\s+)(SG_)(\s+)(\d+)(\s+)(\w+)(\s+)(".*?")(;)', r'(\s+)(SG_)(\s+)(\d+)(\s+)(\w+)(\s+)',
bygroups( bygroups(
token.Whitespace, token.Whitespace,
token.Keyword, token.Keyword,
@ -154,8 +153,6 @@ class CanbusDbcLexer(RegexLexer):
token.Whitespace, token.Whitespace,
token.Name, token.Name,
token.Whitespace, token.Whitespace,
token.String,
token.Punctuation,
), ),
), ),
], ],