mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
Cleanup token abbreviation generation script
This commit is contained in:
parent
e8d405fc99
commit
08daabe1c3
@ -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")
|
@ -1,5 +1,4 @@
|
||||
require "./actions"
|
||||
require "./constants"
|
||||
require "./formatter"
|
||||
require "./rules"
|
||||
require "./styles"
|
||||
|
@ -22,6 +22,7 @@ module Tartrazine
|
||||
"GenericSubheading" => "gs",
|
||||
"GenericTraceback" => "gt",
|
||||
"GenericUnderline" => "gu",
|
||||
"Highlight" => "hl",
|
||||
"Keyword" => "k",
|
||||
"KeywordConstant" => "kc",
|
||||
"KeywordDeclaration" => "kd",
|
@ -1,5 +1,4 @@
|
||||
require "./actions"
|
||||
require "./constants"
|
||||
require "./formatter"
|
||||
require "./rules"
|
||||
require "./styles"
|
||||
|
@ -1,3 +1,4 @@
|
||||
require "../constants/token_abbrevs.cr"
|
||||
require "../formatter"
|
||||
|
||||
module Tartrazine
|
||||
|
@ -1,5 +1,4 @@
|
||||
require "./actions"
|
||||
require "./constants"
|
||||
require "./formatter"
|
||||
require "./rules"
|
||||
require "./styles"
|
||||
|
@ -1,5 +1,4 @@
|
||||
require "./actions"
|
||||
require "./constants"
|
||||
require "./formatter"
|
||||
require "./rules"
|
||||
require "./styles"
|
||||
|
@ -1,5 +1,4 @@
|
||||
require "./actions"
|
||||
require "./constants"
|
||||
require "./formatter"
|
||||
require "./rules"
|
||||
require "./styles"
|
||||
|
Loading…
Reference in New Issue
Block a user