From 8fc4240142ee7a0fb96282c5d0f703a46d872944 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Mon, 27 Jun 2016 18:50:31 +0200 Subject: [PATCH] Ignore preprocessor commands while scanning for globals. The pragma warnings were duplicated, one during globals scan, another during actual parsing. This should fix it. This is somewhat potentially dangerous, as some directives (pragmas, notably) could in future affect the global scan phase by changing the language. --- lslopt/lslparse.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lslopt/lslparse.py b/lslopt/lslparse.py index d7eac9d..470aea9 100644 --- a/lslopt/lslparse.py +++ b/lslopt/lslparse.py @@ -318,6 +318,10 @@ class parser(object): def ProcessDirective(self, directive): """Process a given preprocessor directive during parsing.""" + # Ignore directives on the first pass + if self.scanglobals: + return + if directive[len(directive)-1:] == '\\': raise EParseInvalidBackslash(self) @@ -2490,6 +2494,7 @@ list lazy_list_set(list L, integer i, list v) # incomplete parsing pass, gathering globals with their types and # function arguments. And that's what we do. + self.scanglobals = True # Tell the lexer not to process directives self.pos = self.errorpos = 0 self.linestart = True self.tok = self.GetToken() @@ -2498,6 +2503,7 @@ list lazy_list_set(list L, integer i, list v) # Restart + self.scanglobals = False self.pos = self.errorpos = 0 self.linestart = True self.tok = self.GetToken()