opcocde-descr.html


001| ####################################################################################################
002| from sys import argv
003| from os import path
004| from goodies import KWARG
005| from files import SPC,EOL,CR,LF, linefile
006| ####################################################################################################
007| BasePath = r'C:\CJS\prj\Python\app\sims\cj68'
008| HtmlPath = path.join(BasePath, 'out')
009| 
010| 
011| class cj68opcodedescfile (dict):
012|     def __init__ (self):
013|         super().__init__()
014|         self.fn = path.join(BasePath, 'cj68-opc-desc.text')
015|         self.fo = linefile(self.fn)
016|         self.fo.load()
017|         self.curr = None
018|         self.in_text = False
019|         self.in_demo = False
020| 
021|         for line in self.fo:
022|             if self.curr is None:
023|                 # Ready state...
024|                 if line.startswith('.name '):
025|                     opcode = line[6:].strip()
026|                     self.curr = {'name':opcode}
027|                 continue
028| 
029|             if self.in_text:
030|                 if line == '.':
031|                     self.in_text = False
032|                     continue
033|                 self.curr['text'].append(line)
034|                 continue
035| 
036|             if self.in_demo:
037|                 if line == '.':
038|                     self.in_demo = False
039|                     continue
040|                 self.curr['demo'].append(line)
041|                 continue
042| 
043|             if line.startswith('..'):
044|                 name = self.curr['name']
045|                 self[name] = self.curr
046|                 self.curr = None
047|                 continue
048| 
049|             if line.startswith('.desc '):
050|                 self.curr['desc'] = line[6:].strip()
051|                 continue
052| 
053|             if line.startswith('.text'):
054|                 self.curr['text'] = []
055|                 self.in_text = True
056|                 continue
057| 
058|             if line.startswith('.demo'):
059|                 self.curr['demo'] = []
060|                 self.in_demo = True
061|                 continue
062| 
063|             raise RuntimeError()
064| 
065| 
066|         for key,rcd in self.items():
067|             print(key)
068|             print(rcd['desc'])
069|             print('text:')
070|             for line in rcd['text']:
071|                 print(line)
072|             print('demo:')
073|             for line in rcd['demo']:
074|                 print(line)
075|             print()
076| 
077| 
078| ####################################################################################################
079| if __name__ == '__main__':
080|     print()
081|     df = cj68opcodedescfile()
082|     print()
083| ####################################################################################################
084| '''eof'''
085|