diff --git a/home/alegen/ipv6tests/parse.py b/home/alegen/repos/nmap/luis/ipv6tests/parse.py index 679bd46..327a0fc 100755 --- a/home/alegen/ipv6tests/parse.py +++ b/home/alegen/repos/nmap/luis/ipv6tests/parse.py @@ -349,7 +349,7 @@ def cartesian_product(a, b): p = [] for x in a: for y in b: - p.append(x + "." + y) + p.append( (x + "." + y[0], y[1]) ) return p class SetParser (object): @@ -405,7 +405,12 @@ class SetParser (object): while self.nt == "*": self.nt = self.get_token() cur = self.parse_simple() - accum = cartesian_product(accum, cur) + cur_split = [] + # split feature name and imputation method + for f in cur: + idx = f.find('/') + cur_split.append( (f[:idx], f[idx + 1:]) ) + accum = cartesian_product(accum, cur_split) return accum @@ -418,7 +423,12 @@ class SetParser (object): self.setvar(varname, self.parse_product()) return [] self.unget_token(varname) - return self.parse_product() + statement = self.parse_product() + if len(statement) == 1: + s = statement[0] + idx = s.find('/') + statement = [ (s[:idx], s[idx + 1:]) ] + return statement def parse(self): feature_names = [] @@ -431,7 +441,13 @@ class SetParser (object): def parse_feature_set(f): parser = SetParser(f) - return parser.parse() + tuples = parser.parse() + features = [] + imp_methods = [] + for feature, imp_method in tuples: + features.append(feature) + imp_methods.append(imp_method) + return (features, imp_methods) parse_feature_set_file = wrap_filename(parse_feature_set)