diff --git a/scripts/trim-src.py b/scripts/trim-src.py index 9867921..5d88a55 100644 --- a/scripts/trim-src.py +++ b/scripts/trim-src.py @@ -59,7 +59,7 @@ class CmdBeautify(TrimSourceCmd): r = '' indent = args.indent_assignments for line in contents.splitlines(True): - m = re.match(r'^ *([a-zA-Z_][a-zA-Z0-9_]*)\s*([?+]*)(=)\s*(.*)', line) + m = re.match(r'^ *([a-zA-Z_][a-zA-Z0-9_]*)\s*([?+:]*)(=)\s*(.*)', line) if m is None: r += line continue diff --git a/tools/python/jwutils/stree/StringTree.py b/tools/python/jwutils/stree/StringTree.py index 653f01a..d67f332 100644 --- a/tools/python/jwutils/stree/StringTree.py +++ b/tools/python/jwutils/stree/StringTree.py @@ -62,8 +62,11 @@ class StringTree: # export l = len(components) if len(path) == 0 or l == 0: assert self.content is None - self.content = cleanup_string(content) + #self.content = cleanup_string(content) + self.content = content slog(DEBUG, " -- content = >" + str(content) + "<, self.content = >" + str(self.content) + "<") + #assert(content != "'antlr_doesnt_understand_vertical_tab'") + assert(content != '"[a-zA-Z0-9+_*/-]"') #self.children[content] = StringTree(None, content) return self @@ -89,10 +92,9 @@ class StringTree: # export def __setitem__(self, key, value): return self.__set(key, value) - def __dump(self, prio, indent=0, caller=None, *args): - if caller is None: - caller = get_caller_pos(1) - slog(prio, (' ' * indent) + str(self.content), caller=caller) + def __dump(self, prio, indent=0, **kwargs): + caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1) + slog(prio, '|' + (' ' * indent) + str(self.content), caller=caller) indent += 2 for name, child in self.children.iteritems(): child.__dump(prio, indent=indent, caller=caller) @@ -110,7 +112,7 @@ class StringTree: # export if len(content) == 0: raise Exception("Tried to set empty content") self.content = content - + def add(self, path, content = None): slog(DEBUG, "adding", content, "at", path, "to", self.content) return self.__set(path, content) @@ -144,7 +146,11 @@ class StringTree: # export return None return self.children[next(reversed(self.children))].content - def dump(self, prio, caller=None, *args): - if caller is None: - caller = get_caller_pos(1) + def dump(self, prio, *args, **kwargs): + caller = kwargs['caller'] if 'caller' in kwargs.keys() else get_caller_pos(1) + msg = '' + if args is not None: + msg = ' ' + ' '.join(args) + ' ' + slog(prio, ",------------" + msg + "----------- >", caller=caller) self.__dump(prio, indent=0, caller=caller) + slog(prio, "`------------" + msg + "----------- <", caller=caller) diff --git a/tools/python/jwutils/stree/serdes.py b/tools/python/jwutils/stree/serdes.py index b3b575f..c36fd2b 100644 --- a/tools/python/jwutils/stree/serdes.py +++ b/tools/python/jwutils/stree/serdes.py @@ -54,7 +54,7 @@ def parse(s): # export if rhs is None: raise Exception("failed to parse assignment", line) - root.add(sec + '.' + cleanup_string(lhs), quote(cleanup_string(rhs))) + root.add(sec + '.' + cleanup_string(lhs), cleanup_string(rhs)) return root def read(path): # export