Skip to content

Commit

Permalink
Lexer now supports multi-line macros
Browse files Browse the repository at this point in the history
  • Loading branch information
agagniere committed Aug 17, 2024
1 parent 4502f87 commit b2cb24c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions extra/pygment/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ class CustomLexer(RegexLexer):
'phase3': [
(r'\w+', Name),
(r'\d[0-9a-zA-Z+-.]*', Number),
(r"'[^']+'", String.Char),
(r"'[^']{0,4}'", String.Char),
(r'"[^"]*"', String),
],
'detect_comment': [
(r'/[*]', Comment.Multiline, 'comment'),
(r'//.*?$', Comment.Single),
],
'detect_prepro' : [
(r'^(#)(\s*)(include)(\s+)([<"][\w/.]+[">])(\s*)([/].*)?',
(r'^(#)(\s*)(include)(\s+)([<"][\w/.]+[">])',
bygroups(Comment.Hashbang,
Whitespace,
Keyword,
Whitespace,
Comment.PreprocFile,
Whitespace,
Whitespace)),
Comment.PreprocFile)),
(r'^(#)(\s*)(define)(\s+)(\w+)(\s+)',
bygroups(Comment.Hashbang,
Whitespace,
Expand Down Expand Up @@ -67,12 +65,14 @@ class CustomLexer(RegexLexer):
],
'prepro' : [
include('detect_comment'),
(r'(\w+)(\s*)([(])', bygroups(Name.Function, Whitespace, Punctuation)),
(r'([A-Z_]+)(\s*)([(])', bygroups(Name.Function, Whitespace, Punctuation)),
(r'[A-Z_]+\b', Name.Constant),
(r'\w+', Name),
(r'[#]+', Operator),
(r'[)(,]+', Punctuation),
(words(('__VA_ARGS__', '__VA_OPT__'), suffix=r'\b'), Name.Variable.Magic),
include('phase3'),
(r'\\\n', Comment, '#push'),
],
'comment' : [
(r'[^*]+', Comment.Multiline),
Expand Down

0 comments on commit b2cb24c

Please sign in to comment.