mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-19 14:43:05 -03:00
Cleanup token abbreviation generation script
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
# Script to generate abbreviations for tokens. Parses all lexers
|
||||
# and styles files to find all token names and generate a unique
|
||||
# abbreviation for each one. The abbreviations are generated by
|
||||
# taking the uppercase letters of the token name and converting
|
||||
# them to lowercase. If the abbreviation is not unique, the script
|
||||
# will print a warning and exit.
|
||||
|
||||
import sys
|
||||
import string
|
||||
import glob
|
||||
@ -40,7 +47,9 @@ for fname in glob.glob("styles/*.xml"):
|
||||
tokens.add(line)
|
||||
check_abbrevs()
|
||||
|
||||
print("Abbreviations = {")
|
||||
for k, v in abbrevs.items():
|
||||
print(f' "{k}" => "{v}",')
|
||||
print("}")
|
||||
with open ("src/constants/token_abbrevs.cr", "w") as outf:
|
||||
outf.write("module Tartrazine\n")
|
||||
outf.write(" Abbreviations = {\n")
|
||||
for k in sorted(abbrevs.keys()):
|
||||
outf.write(f' "{k}" => "{abbrevs[k]}",\n')
|
||||
outf.write(" }\nend\n")
|
Reference in New Issue
Block a user