This is a code for simple nested macroprocessor written in Python
- Open input file in read and create mnt, fppt and mdt
- Declare lists
- if MACRO in words > count ‘&’ in words > write(words1[0]+count+line no.) in mnt
- write(words[1]+words[-count]+x) > name=words[1] > append(words[-count]),words[1],x > count- - > x++
- count != 0 > goto 4
- line ++
- if words[-1] in fp > y= fp.index(words[-1]) > write(mname[y]+words[0]+pp[y])
- else > write(name+words[0]+words[-1])
- line++ > y=0
- if MEND ! in words > goto 7
- write(words[0])
- x=1 > close all files
- open all files in read > create papt
- i in range(lines)
- if words[0] == words1[0] > x=words1[-2] > y=1
- write(words[0]+y+words[-x]) > y++ > x - -
- if x!=0 > goto 16
- if j != lines1 > goto 15
- if i != lines > goto 14
- close all files
- Open all files in read > create expanded code
- if MACRO in words
- for (line in f) > if MEND in words : break > else : continue
- else > if words[0] in operation : write(line)
- else:
- j++ > if words1[0]==words[0]
- line2=lines2[k]
- if words[0]==words2[0] & words1[-1]==words2[-2]: write(words[1]+words2[-1]) ,flag=0, break
- else flag=1
- k++ > if k!= lines2 : goto 27
- if flag==1: write(words1[1]+words1[-1]), flag=0
- if j!= lines1 : goto 26
- if ! EOF : goto 22
- Close all files