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 sys
|
||||||
import string
|
import string
|
||||||
import glob
|
import glob
|
||||||
@ -40,7 +47,9 @@ for fname in glob.glob("styles/*.xml"):
|
|||||||
tokens.add(line)
|
tokens.add(line)
|
||||||
check_abbrevs()
|
check_abbrevs()
|
||||||
|
|
||||||
print("Abbreviations = {")
|
with open ("src/constants/token_abbrevs.cr", "w") as outf:
|
||||||
for k, v in abbrevs.items():
|
outf.write("module Tartrazine\n")
|
||||||
print(f' "{k}" => "{v}",')
|
outf.write(" Abbreviations = {\n")
|
||||||
print("}")
|
for k in sorted(abbrevs.keys()):
|
||||||
|
outf.write(f' "{k}" => "{abbrevs[k]}",\n')
|
||||||
|
outf.write(" }\nend\n")
|
@ -1,5 +1,4 @@
|
|||||||
require "./actions"
|
require "./actions"
|
||||||
require "./constants"
|
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "./rules"
|
require "./rules"
|
||||||
require "./styles"
|
require "./styles"
|
||||||
|
@ -22,6 +22,7 @@ module Tartrazine
|
|||||||
"GenericSubheading" => "gs",
|
"GenericSubheading" => "gs",
|
||||||
"GenericTraceback" => "gt",
|
"GenericTraceback" => "gt",
|
||||||
"GenericUnderline" => "gu",
|
"GenericUnderline" => "gu",
|
||||||
|
"Highlight" => "hl",
|
||||||
"Keyword" => "k",
|
"Keyword" => "k",
|
||||||
"KeywordConstant" => "kc",
|
"KeywordConstant" => "kc",
|
||||||
"KeywordDeclaration" => "kd",
|
"KeywordDeclaration" => "kd",
|
@ -1,5 +1,4 @@
|
|||||||
require "./actions"
|
require "./actions"
|
||||||
require "./constants"
|
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "./rules"
|
require "./rules"
|
||||||
require "./styles"
|
require "./styles"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
require "../constants/token_abbrevs.cr"
|
||||||
require "../formatter"
|
require "../formatter"
|
||||||
|
|
||||||
module Tartrazine
|
module Tartrazine
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require "./actions"
|
require "./actions"
|
||||||
require "./constants"
|
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "./rules"
|
require "./rules"
|
||||||
require "./styles"
|
require "./styles"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require "./actions"
|
require "./actions"
|
||||||
require "./constants"
|
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "./rules"
|
require "./rules"
|
||||||
require "./styles"
|
require "./styles"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
require "./actions"
|
require "./actions"
|
||||||
require "./constants"
|
|
||||||
require "./formatter"
|
require "./formatter"
|
||||||
require "./rules"
|
require "./rules"
|
||||||
require "./styles"
|
require "./styles"
|
||||||
|
Loading…
Reference in New Issue
Block a user