From ded7240adceeadb5bb8d195ebd9cccbdb29c53d7 Mon Sep 17 00:00:00 2001 From: virtuald Date: Tue, 22 Aug 2023 14:09:57 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20robotpy/?= =?UTF-8?q?cxxheaderparser@1ba625a13b4c3b35c1488751aa7921a822e8e7a4=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cxxheaderparser/lexer.py | 15 +++++++-------- cxxheaderparser/version.py | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cxxheaderparser/lexer.py b/cxxheaderparser/lexer.py index 7003821..b62e660 100644 --- a/cxxheaderparser/lexer.py +++ b/cxxheaderparser/lexer.py @@ -19,7 +19,7 @@ class LexError(CxxParseError): else: Protocol = object -_line_re = re.compile(r'^#line (\d+) "(.*)"') +_line_re = re.compile(r'^\#[\t ]*line (\d+) "(.*)"') _multicomment_re = re.compile("\n[\\s]+\\*") @@ -176,7 +176,6 @@ class PlyLexer: # Comments "COMMENT_SINGLELINE", "COMMENT_MULTILINE", - "LINE_DIRECTIVE", "PRAGMA_DIRECTIVE", "INCLUDE_DIRECTIVE", "PP_DIRECTIVE", @@ -438,12 +437,6 @@ def t_NAME(self, t: LexToken) -> LexToken: t.type = t.value return t - @TOKEN(r'\#[\t ]*line (\d+) "(.*)"') - def t_LINE_DIRECTIVE(self, t: LexToken) -> None: - m = t.lexmatch - self.filename = m.group(2) - self.line_offset = 1 + self.lex.lineno - int(m.group(1)) - @TOKEN(r"\#[\t ]*pragma") def t_PRAGMA_DIRECTIVE(self, t: LexToken) -> LexToken: return t @@ -454,6 +447,12 @@ def t_INCLUDE_DIRECTIVE(self, t: LexToken) -> LexToken: @TOKEN(r"\#(.*)") def t_PP_DIRECTIVE(self, t: LexToken): + # handle line macros + m = _line_re.match(t.value) + if m: + self.filename = m.group(2) + self.line_offset = 1 + self.lex.lineno - int(m.group(1)) + return None # ignore C++23 warning directive if t.value.startswith("#warning"): return diff --git a/cxxheaderparser/version.py b/cxxheaderparser/version.py index e913ada..86e776c 100644 --- a/cxxheaderparser/version.py +++ b/cxxheaderparser/version.py @@ -1 +1 @@ -__version__ = '0.0.0-95-gdffcbf9' +__version__ = '0.0.0-97-g1ba625a'