Skip to content

Commit

Permalink
Update the lexer for it to be slightly more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
agagniere committed Mar 7, 2024
1 parent 3ca7207 commit 877f691
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions extra/pygment/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,35 @@ class CustomLexer(RegexLexer):
(r'//.*?$', Comment.Single),
],
'detect_prepro' : [
(r'^(#)(include)(\s+)([<"][\w/.]+[">])',
(r'^(#)(\s*)(include)(\s+)([<"][\w/.]+[">])(\s*)([/].*)?',
bygroups(Comment.Hashbang,
Whitespace,
Keyword,
Whitespace,
Comment.PreprocFile)),
(r'^(#)(define)(\s+)(\w+)(\s+)',
Comment.PreprocFile,
Whitespace,
Whitespace)),
(r'^(#)(\s*)(define)(\s+)(\w+)(\s+)',
bygroups(Comment.Hashbang,
Whitespace,
Keyword,
Whitespace,
Name.Constant,
Whitespace),
'prepro'),
(r'^(#)(define)(\s+)(\w+)([(])',
(r'^(#)(\s*)(define)(\s+)(\w+)([(])',
bygroups(Comment.Hashbang,
Whitespace,
Keyword,
Whitespace,
Name.Function,
Punctuation),
('prepro', 'param_list')),
(r'^(#)(\w*if\w*|el[si][ef])(\s+)$',
(r'^(#)(\s*)(\w*if\w*|el[si][ef])(.*)$',
bygroups(Comment.Hashbang,
Whitespace,
Keyword,
Whitespace)),
Comment.Preproc)),
(r'^(#)(.*)$',
bygroups(Comment.Hashbang,
Comment.Preproc)),
Expand Down

0 comments on commit 877f691

Please sign in to comment.