Now we can fix up links in groups if we wish. Or all at once.
authorDavid Anderson <davea42@earthlink.net>
Thu, 31 May 2012 19:46:54 +0000 (12:46 -0700)
committerDavid Anderson <davea42@earthlink.net>
Thu, 31 May 2012 19:46:54 +0000 (12:46 -0700)
With test code too.

dwarf5/tools/Makefile
dwarf5/tools/anylink.base [new file with mode: 0644]
dwarf5/tools/anylink.in [new file with mode: 0644]
dwarf5/tools/anylink.py
dwarf5/tools/anylinkt.base [new file with mode: 0644]
dwarf5/tools/anylinkt.in [new file with mode: 0644]
dwarf5/tools/attrlink.py
dwarf5/tools/formlink.py
dwarf5/tools/taglink.py

index b2d9f64..c2af124 100644 (file)
@@ -11,32 +11,49 @@ clean:
 test:  
        python printtokens.py test1.in >test1.tmp
        diff test1.tmp test1.base
+       #       
        python copyfile.py test1.in 
        diff test1.in test1.in.out
+       #       
        python refclassfixup.py test2.in
        diff test2.in.out test2.base
        # checking for idempotence
        python refclassfixup.py test2.in.out
        diff test2.in.out test2.in.out.out
+       #       
        python taglink.py test1.in
        diff test1.in.out taglink.base
        # checking for idempotence
        python taglink.py test1.in.out
        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
        python attrlink.py attrlink.in
+       #       
        diff attrlink.in.out attrlink.base
        # checking for idempotence
        python attrlink.py attrlink.in.out
        diff attrlink.in.out.out attrlink.base
+       #       
        python formlink.py formlink.in
        diff formlink.in.out formlink.base
        python formlink.py formlink.in.out
        diff formlink.in.out.out formlink.base
+       #       
+       python anylink.py -all anylink.in
+       diff anylink.in.out anylink.base
+       python anylink.py -all anylink.in.out
+       diff anylink.in.out.out anylink.base
+       #       
+       python anylink.py -t DW_ACCESS_ -t DW_OP_ anylinkt.in
+       diff anylinkt.in.out anylinkt.base
+       python anylink.py -t DW_ACCESS_ -t DW_OP_ anylinkt.in.out
+       diff anylinkt.in.out.out anylinkt.base
      
diff --git a/dwarf5/tools/anylink.base b/dwarf5/tools/anylink.base
new file mode 100644 (file)
index 0000000..1b42287
--- /dev/null
@@ -0,0 +1,22 @@
+\livelink{chap:DWACCESSprivate}{DW_ACCESS_private}
+\livelink{chap:DWADDRfar16}{DW_ADDR_far16}
+\livelink{chap:DWATcompdir}{DW_AT_comp_dir}
+\livelink{chap:DWATEaddress}{DW_ATE_address}
+\livelink{chap:DWCCnocall}{DW_CC_nocall}
+\livelink{chap:DWCFAadvanceloc}{DW_CFA_advance_loc}
+\livelink{chap:DWCHILDRENno}{DW_CHILDREN_no}
+\livelink{chap:DWDSClabel}{DW_DSC_label}
+\livelink{chap:DWDSleadingoverpunch}{DW_DS_leading_overpunch}
+\livelink{chap:DWENDbig}{DW_END_big}
+\livelink{chap:DWFORMaddr}{DW_FORM_addr}
+\livelink{chap:DWIDcaseinsensitive}{DW_ID_case_insensitive}
+\livelink{chap:DWINLdeclaredinlined}{DW_INL_declared_inlined}
+\livelink{chap:DWLANGAda83}{DW_LANG_Ada83}
+\livelink{chap:DWLNEdefinefile}{DW_LNE_define_file}
+\livelink{chap:DWLNSconstaddpc}{DW_LNS_const_add_pc}
+\livelink{chap:DWMACINFOdefine}{DW_MACINFO_define}
+\livelink{chap:DWOPabs}{DW_OP_abs}
+\livelink{chap:DWORDcolmajor}{DW_ORD_col_major}
+\livelink{chap:DWTAGaccessdeclaration}{DW_TAG_access_declaration}
+\livelink{chap:DWVIRTUALITYpurevirtual}{DW_VIRTUALITY_pure_virtual}
+\livelink{chap:DWVISexported}{DW_VIS_exported}
diff --git a/dwarf5/tools/anylink.in b/dwarf5/tools/anylink.in
new file mode 100644 (file)
index 0000000..580dea2
--- /dev/null
@@ -0,0 +1,22 @@
+DW_ACCESS_private
+DW_ADDR_far16
+DW_AT_comp_dir
+DW_ATE_address
+DW_CC_nocall
+DW_CFA_advance_loc
+DW_CHILDREN_no
+DW_DSC_label
+DW_DS_leading_overpunch
+DW_END_big
+DW_FORM_addr
+DW_ID_case_insensitive
+DW_INL_declared_inlined
+DW_LANG_Ada83
+DW_LNE_define_file
+DW_LNS_const_add_pc
+DW_MACINFO_define
+DW_OP_abs
+DW_ORD_col_major
+DW_TAG_access_declaration
+DW_VIRTUALITY_pure_virtual
+DW_VIS_exported
index 9e5927d..34c5551 100644 (file)
@@ -5,7 +5,7 @@
 import sys
 import fileio
 
-global myprefix
+global mytarglist
 
 def ischar(tok,c):
    if tok._class != "ind":
@@ -43,10 +43,11 @@ def isdesiredname(stdname):
       We don't want something like plain DW_TAG  or 
       plain DW_TAG_ to get modified.
   """
-  global myprefix
-  if stdname.startswith(myprefix):
-    if len(stdname) > len(myprefix):
-      return "y"
+  global mytarglist
+  for mt  in mytarglist:
+    if stdname.startswith(mt):
+      if len(stdname) > len(mt):
+        return "y"
   return "n"
 
 def dwspace(tok):
@@ -108,20 +109,93 @@ def transfunc(linetoks):
     # End of for loop.
   return outtoks
 
-def read_args(targprefix):
+def process_files(targlist,filelist):
+  global mytarglist
+  mytarglist = targlist
+  dwf = fileio.readFilelist(filelist)
+  dwf.dwtransformline(transfunc)
+  dwf.dwwrite()
+
+def read_file_args(targlist):
   cur = 1
-  global myprefix
-  myprefix = targprefix
   filelist = []
   while  len(sys.argv) > cur:
     v = sys.argv[cur]
     filelist += [v]
     cur = int(cur) + 1
+  process_files(targlist,filelist)
+  
 
-  dwf = fileio.readFilelist(filelist)
-  dwf.dwtransformline(transfunc)
-  dwf.dwwrite()
 
+legalprefix = ["DW_ACCESS_",
+"DW_ADDR_",
+"DW_AT_",
+"DW_ATE_",
+"DW_CC_",
+"DW_CFA_",
+"DW_CHILDREN_",
+"DW_DSC_",
+"DW_DS_",
+"DW_END_",
+"DW_FORM_",
+"DW_ID_",
+"DW_INL_",
+"DW_LANG_",
+"DW_LNE_",
+"DW_LNS_",
+"DW_MACINFO_",
+"DW_OP_",
+"DW_ORD_",
+"DW_TAG_",
+"DW_VIRTUALITY_",
+"DW_VIS_" ]
+
+def islegalprefix(prefix):
+  for t in legalprefix:
+    if t == prefix:
+      # All is ok.
+      return "y"
+  return "n"
+
+def printlegals():
+  print "legal tarrgets  for -t options are: ",
+  for t in legalprefix:
+    print legalprefix,
+  print ""
   
 
+def read_all_args():
+  filelist = []
+  targlist = []
+  cur = 1
+  while  len(sys.argv) > cur:
+    v = sys.argv[cur]
+    if v == "-all":
+      targlist = legalprefix
+    elif v == "-t":
+      cur = int(cur) + 1
+      if cur >= len(sys.argv):
+        print >> sys.stderr , "A -t has no target list entry"
+        sys.exit(1)
+      v2 = sys.argv[cur]
+      if islegalprefix(v2) == "y":
+        targlist += [v2]
+      else:
+        print >> sys.stderr , "A -t has invalid target list entry", v2
+        sys.exit(1)
+    else:
+      filelist += [v]
+    cur = int(cur) + 1
+  if len(targlist) < 1:
+    print >> sys.stderr , "No targets specified."
+    sys.exit(1)
+  if len(filelist) < 1:
+    print >> sys.stderr , "No files specified."
+    sys.exit(1)
+  process_files(targlist,filelist)
+
+#  anylink [-t <class>] ... [file] ...
+
+if __name__ == '__main__':
+  read_all_args()
 
diff --git a/dwarf5/tools/anylinkt.base b/dwarf5/tools/anylinkt.base
new file mode 100644 (file)
index 0000000..48f6270
--- /dev/null
@@ -0,0 +1,22 @@
+\livelink{chap:DWACCESSprivate}{DW_ACCESS_private}
+DW_ADDR_far16
+DW_AT_comp_dir
+DW_ATE_address
+DW_CC_nocall
+DW_CFA_advance_loc
+DW_CHILDREN_no
+DW_DSC_label
+DW_DS_leading_overpunch
+DW_END_big
+DW_FORM_addr
+DW_ID_case_insensitive
+DW_INL_declared_inlined
+DW_LANG_Ada83
+DW_LNE_define_file
+DW_LNS_const_add_pc
+DW_MACINFO_define
+\livelink{chap:DWOPabs}{DW_OP_abs}
+DW_ORD_col_major
+DW_TAG_access_declaration
+DW_VIRTUALITY_pure_virtual
+DW_VIS_exported
diff --git a/dwarf5/tools/anylinkt.in b/dwarf5/tools/anylinkt.in
new file mode 100644 (file)
index 0000000..580dea2
--- /dev/null
@@ -0,0 +1,22 @@
+DW_ACCESS_private
+DW_ADDR_far16
+DW_AT_comp_dir
+DW_ATE_address
+DW_CC_nocall
+DW_CFA_advance_loc
+DW_CHILDREN_no
+DW_DSC_label
+DW_DS_leading_overpunch
+DW_END_big
+DW_FORM_addr
+DW_ID_case_insensitive
+DW_INL_declared_inlined
+DW_LANG_Ada83
+DW_LNE_define_file
+DW_LNS_const_add_pc
+DW_MACINFO_define
+DW_OP_abs
+DW_ORD_col_major
+DW_TAG_access_declaration
+DW_VIRTUALITY_pure_virtual
+DW_VIS_exported
index 8973ed2..8619cd7 100644 (file)
@@ -6,6 +6,6 @@ import sys
 import anylink
 
 if __name__ == '__main__':
-  anylink.read_args("DW_AT_")
+  anylink.read_file_args(["DW_AT_"])
 
 
index e28d9e5..2413836 100644 (file)
@@ -6,6 +6,6 @@ import sys
 import anylink
 
 if __name__ == '__main__':
-  anylink.read_args("DW_FORM_")
+  anylink.read_file_args(["DW_FORM_"])
 
 
index 64a80bc..e72a763 100644 (file)
@@ -6,7 +6,7 @@ import sys
 import anylink
 
 if __name__ == '__main__':
-  anylink.read_args("DW_TAG_")
+  anylink.read_file_args(["DW_TAG_"])