Created tohypyen.py to clean up all DW_* entries
authorDavid Anderson <davea42@earthlink.net>
Thu, 31 May 2012 14:29:23 +0000 (07:29 -0700)
committerDavid Anderson <davea42@earthlink.net>
Thu, 31 May 2012 14:29:23 +0000 (07:29 -0700)
so latex can adjust lines right.

dwarf5/tools/Makefile
dwarf5/tools/printstandard.base
dwarf5/tools/printstandard.py
dwarf5/tools/tohyphen.base [new file with mode: 0644]
dwarf5/tools/tohyphen.in [new file with mode: 0644]
dwarf5/tools/tohyphen.py [new file with mode: 0644]

index 0d7d738..77f82ae 100644 (file)
@@ -25,4 +25,9 @@ test:
        diff test1.in.out.out taglink.base
        python printstandard.py printstandard.in >printstandard.out
        diff printstandard.out printstandard.base
+       python tohyphen.py tohyphen.in
+       diff tohyphen.in.out tohyphen.base
+       # checking for idempotence
+       python tohyphen.py tohyphen.in.out
+       diff tohyphen.in.out.out tohyphen.base
      
index 44ba414..54b7954 100644 (file)
@@ -12,4 +12,3 @@ DW_CFA
 DW_TAG_access_declaration
 DW_TAG_no_backslash
 DW_TAG_access_declaration
-printstandard.in.out
index 33e5b55..3e5620e 100644 (file)
@@ -32,7 +32,6 @@ def read_args():
 
   dwf = fileio.readFilelist(filelist)
   dwf.dwtransformline(transfunc)
-  dwf.dwwrite()
 
 if __name__ == '__main__':
   read_args()
diff --git a/dwarf5/tools/tohyphen.base b/dwarf5/tools/tohyphen.base
new file mode 100644 (file)
index 0000000..9fb2be1
--- /dev/null
@@ -0,0 +1,19 @@
+
+appropriate    prefix (DW\-\_TAG\-\_foo, DW\-\_AT\-\_foo, 
+DW\-\_END\-\_line, DW\-\_ATE\-\_x, DW\-\_OP\-\_foo,
+DW\-\_TAG
+DW\-\_TAG\-\_
+DW\-\_LANG, DW\-\_LNE, DW\-\_CC or DW\-\_CFA respectively) followed by
+\_lo\_user or \_hi\_user.
+
+\endlastfoot
+\livelink{chap:DWTAGaccessdeclaration}{  DW\-\_TAG\-\_access\-\_declaration}
+& DECL \\
+
+    DW\-\_TAG\-\_foo3  DW\-\_TAG\-\_variable
+
+information entry with the tag
+\livetarg{chap:DWTAGaccessdeclaration}{DW\-\_TAG\-\_access\-\_declaration}.
+Each
+such entry is a child of the class or structure type entry.
+
diff --git a/dwarf5/tools/tohyphen.in b/dwarf5/tools/tohyphen.in
new file mode 100644 (file)
index 0000000..51dfe43
--- /dev/null
@@ -0,0 +1,19 @@
+
+appropriate    prefix (DW\_TAG\_foo, DW\_AT\_foo, 
+DW\_END_line, DW\_ATE_x, DW\_OP_foo,
+DW\_TAG
+DW\_TAG_
+DW\_LANG, DW\_LNE, DW\_CC or DW\_CFA respectively) followed by
+\_lo\_user or \_hi\_user.
+
+\endlastfoot
+\livelink{chap:DWTAGaccessdeclaration}{  DW\-\_TAG\-\_access\-\_declaration}
+& DECL \\
+
+    DW_TAG_foo3  DW_TAG_variable
+
+information entry with the tag
+\livetarg{chap:DWTAGaccessdeclaration}{DW\_TAG\_access\_declaration}.
+Each
+such entry is a child of the class or structure type entry.
+
diff --git a/dwarf5/tools/tohyphen.py b/dwarf5/tools/tohyphen.py
new file mode 100644 (file)
index 0000000..58e523f
--- /dev/null
@@ -0,0 +1,53 @@
+# Copyright 2012 DWARF Debugging Information Format Committee
+#
+# Convert DW_ and DW\_ names to DW\-\_ 
+#
+
+import sys
+import fileio
+
+def convertToHyphen(s):
+  out = []
+  for c in s:
+    if c == "_":
+      out += ["\\"]
+      out += ["-"]
+      out += ["\\"]
+    out += [c]  
+  os = ''.join(out)
+  return os
+
+def transfunc(linetoks):
+  if len(linetoks) < 1:
+    return linetoks
+  outtoks = []
+  for t in linetoks:
+    stdname= ''.join(t._std)
+    if stdname.startswith("DW_") != 0:
+      xs = convertToHyphen(stdname)
+      x = fileio.dwtoken()
+      x.insertid(xs)
+      x.finishUpId()
+      outtoks += [x]
+    else:
+      outtoks += [t]
+    # End of for loop.
+  return outtoks
+
+def read_args():
+  cur = 1
+  filelist = []
+  while  len(sys.argv) > cur:
+    v = sys.argv[cur]
+    filelist += [v]
+    cur = int(cur) + 1
+
+  dwf = fileio.readFilelist(filelist)
+  dwf.dwtransformline(transfunc)
+  dwf.dwwrite()
+
+if __name__ == '__main__':
+  read_args()
+  
+
+