forked from contradictioned/mips-syntax
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.py
43 lines (24 loc) · 775 Bytes
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from __future__ import print_function
import os
import glob
import re
with open('RISCV.txt') as file:
linhas = file.readlines()
for arquivo in glob.glob('mips snippets/*.sublime-snippet'):
print('Removendo:', arquivo)
os.remove(arquivo)
for linha in linhas:
print(linha)
pedacos = re.split(r'\s{2,}', linha)
funcName = pedacos[0]
CDATA = pedacos[1]
comentario = pedacos[2].strip()
content = '''<snippet>
<description>'''+comentario+'''</description>
<content><![CDATA['''+CDATA+''']]></content>
<tabTrigger>'''+funcName+'''</tabTrigger>
<scope>source.riscv</scope>
</snippet>'''
fileDest = 'mips snippets/'+funcName+'.sublime-snippet'
with open(fileDest, 'w') as file:
file.write(content)