verify fields.txt forms' field separators ('|') line up with headers'
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 5 May 2023 00:34:27 +0000 (17:34 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:17 +0000 (19:51 +0100)
openpower/isatables/fields.text
src/openpower/decoder/power_fields.py

index 451fb57d1b131c36c3af4ea8476f33644cc872d2..89ad7530670db1a54a7d5d7b35ebba25adb2e19a 100644 (file)
 
 # 1.6.7.1 DCT-FORM
 
-    |0     |6     |11      |16     |21      |26    |31 |
+    |0     |6     |11      |16     |21      |26    |31  |
     | PO   |  FRT |   FRA  |   FRB |   //   |   XO | Rc |
 
 # 1.6.8 XL-FORM
     | PO | RT | IT | CVM | FRB | OE | XO | Rc |
 
 # 1.6.17 A-FORM
-    |0     |6     |11      |16     |21      |26    |31 |
+    |0     |6     |11     |16      |21      |26    |31 |
     | PO   |  FRT |  FRA  |  FRB   |   FRC  |   XO |Rc |
     | PO   |  FRT |  FRA  |  FRB   |   ///  |   XO |Rc |
     | PO   |  FRT |  FRA  |  ///   |   FRC  |   XO |Rc |
index b0f179099f3aa01036a7a760e7b4594bb40c3f9b..892af1d86d1bd4236ace6dd0c993c925d7be609f 100644 (file)
@@ -489,7 +489,7 @@ class DecodeFields:
         #print ("decode", txt)
         forms = {}
         reading_data = False
-        for l in txt:
+        for lineno, l in enumerate(txt):
             l = l.strip()
             if len(l) == 0:
                 continue
@@ -497,7 +497,20 @@ class DecodeFields:
                 if l[0] == '#':
                     reading_data = False
                 else:
-                    forms[heading].append(l)
+                    form = forms[heading]
+                    form.append(l)
+                    if len(form) <= 1:
+                        continue
+                    for i, ch in enumerate(l):
+                        if ch != '|':
+                            continue
+                        if i >= len(form[0]) or form[0][i] != '|':
+                            col = len(txt[lineno]) - len(txt[lineno].lstrip())
+                            col += i + 1
+                            raise SyntaxError(
+                                "form line field separator ('|') "
+                                "with no corresponding separator in header",
+                                (self.fname, lineno + 1, col, txt[lineno]))
             if not reading_data:
                 assert l[0] == '#'
                 heading = l[1:].strip()