scons icon indicating copy to clipboard operation
scons copied to clipboard

D tool: parsing of import statement is not correct

Open bdbaddog opened this issue 7 years ago • 1 comments

This issue was originally created at: 2015-02-22 01:21:11. This issue was reported by: russel.

russel said at 2015-02-22 01:21:11 This report was sent to me via email:

Further, I've tracked down another bug in SCons/Scanner/D.py:

The regexp https://bitbucket.org/per_nordlow/scons/src/7e4dd9c8304d8f197c0261df4ff18423f02775d9/src/engine/SCons/Scanner/D.py?at=default#cl-50 (note: bitbucket gone, assuming it meant this one: https://github.com/SCons/scons/blob/c452f92126499dd213ac1593791212cc73ecb50a/SCons/Scanner/D.py#L43)

doesn't cover patterns such as

import IMPORT_PATH* : SYMBOL*;

only

import IMPORT_PATH;

I'm guessing both regex (self.cre) and self.cre2 needs to be fixed right? But I don't quite understand how they are related. My guess is that self.cre matches the whole import statements and self.cre2 matches parts of it. Am I correct? If so self.cre2 needs to be correct to handle cases such as

import X, *Y, Z;*

Do you have any idea how to fix the regexps so that it handles these cases?

My first try is to change

p = 'import\s+(?:[a-zA-Z0-9_.]+)\s*(?:,\s*(?:[a-zA-Z0-9_.]+)\s*)*;'

to

p = 'import\s+(?:[a-zA-Z0-9_.]+)\s*(?:,\s*(?:[a-zA-Z0-9_.]+)*(?:\s*:\s*[a-zA-Z0-9_.]+)?*\s*)*;'

Python:

import re
re.match(p, "import first : f")
re.match(p, "import first : f, second : g;")

but it doesn't work. I've tried debugging this, but in vain. Something about regexp operator associativity.

bdbaddog avatar Jan 02 '18 15:01 bdbaddog

The D regex doesn't look like the one referenced in this report, perhaps this is not an issue any longer?

mwichmann avatar Jan 22 '24 15:01 mwichmann