mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
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.
This commit is contained in:
parent
633c31df6c
commit
8fc4240142
1 changed files with 6 additions and 0 deletions
|
@ -318,6 +318,10 @@ class parser(object):
|
||||||
def ProcessDirective(self, directive):
|
def ProcessDirective(self, directive):
|
||||||
"""Process a given preprocessor directive during parsing."""
|
"""Process a given preprocessor directive during parsing."""
|
||||||
|
|
||||||
|
# Ignore directives on the first pass
|
||||||
|
if self.scanglobals:
|
||||||
|
return
|
||||||
|
|
||||||
if directive[len(directive)-1:] == '\\':
|
if directive[len(directive)-1:] == '\\':
|
||||||
raise EParseInvalidBackslash(self)
|
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
|
# incomplete parsing pass, gathering globals with their types and
|
||||||
# function arguments. And that's what we do.
|
# function arguments. And that's what we do.
|
||||||
|
|
||||||
|
self.scanglobals = True # Tell the lexer not to process directives
|
||||||
self.pos = self.errorpos = 0
|
self.pos = self.errorpos = 0
|
||||||
self.linestart = True
|
self.linestart = True
|
||||||
self.tok = self.GetToken()
|
self.tok = self.GetToken()
|
||||||
|
@ -2498,6 +2503,7 @@ list lazy_list_set(list L, integer i, list v)
|
||||||
|
|
||||||
# Restart
|
# Restart
|
||||||
|
|
||||||
|
self.scanglobals = False
|
||||||
self.pos = self.errorpos = 0
|
self.pos = self.errorpos = 0
|
||||||
self.linestart = True
|
self.linestart = True
|
||||||
self.tok = self.GetToken()
|
self.tok = self.GetToken()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue