diff options
author | June McEnroe <june@causal.agency> | 2021-01-13 16:42:30 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2021-01-13 16:42:30 -0500 |
commit | b10e81ef8fbc7e644dd72c2ee94b9e09eeac62f8 (patch) | |
tree | 1b9d9471153d49dc500cd9b7f1e6d50cfb505ec0 /bin | |
parent | Move text "lexer" to hilex.c (diff) | |
download | src-b10e81ef8fbc7e644dd72c2ee94b9e09eeac62f8.tar.gz src-b10e81ef8fbc7e644dd72c2ee94b9e09eeac62f8.zip |
Shorten hilex class names
Diffstat (limited to '')
-rw-r--r-- | bin/c11.l | 6 | ||||
-rw-r--r-- | bin/hilex.c | 44 | ||||
-rw-r--r-- | bin/hilex.h | 8 | ||||
-rw-r--r-- | bin/html.sh | 12 | ||||
-rw-r--r-- | bin/make.l | 18 | ||||
-rw-r--r-- | bin/man1/hilex.1 | 42 |
6 files changed, 70 insertions, 60 deletions
diff --git a/bin/c11.l b/bin/c11.l index ce310ffc..0cee3a23 100644 --- a/bin/c11.l +++ b/bin/c11.l @@ -76,7 +76,7 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while | {ident} { return Macro; } } -{ident} { return Identifier; } +{ident} { return Ident; } "//"([^\n]|"\\\n")* | "/*"([^*]|"*"[^/])*"*"+"/" { @@ -106,13 +106,13 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while | "\\x"([[:xdigit:]]{2}) | "\\u"([[:xdigit:]]{4}) | "\\U"([[:xdigit:]]{8}) { - return StringEscape; + return Escape; } } <StringLiteral>{ "%%" | "%"[ #+-0]*{width}?("."{width})?([Lhjltz]|hh|ll)?[AEFGXacdefginopsux] { - return StringFormat; + return Format; } } diff --git a/bin/hilex.c b/bin/hilex.c index a5c682ac..4ce86450 100644 --- a/bin/hilex.c +++ b/bin/hilex.c @@ -92,15 +92,15 @@ enum Option { }; typedef void Header(const char *opts[]); -typedef void Format(const char *opts[], enum Class class, const char *text); +typedef void Output(const char *opts[], enum Class class, const char *text); static const char *SGR[ClassCap] = { - [Keyword] = "37", - [Macro] = "32", - [Comment] = "34", - [String] = "36", - [StringFormat] = "36;1;96", - [Interpolation] = "33", + [Keyword] = "37", + [Macro] = "32", + [Comment] = "34", + [String] = "36", + [Format] = "36;1;96", + [Subst] = "33", }; static void ansiFormat(const char *opts[], enum Class class, const char *text) { @@ -128,12 +128,12 @@ debugFormat(const char *opts[], enum Class class, const char *text) { } static const char *IRC[ClassCap] = { - [Keyword] = "\00315", - [Macro] = "\0033", - [Comment] = "\0032", - [String] = "\00310", - [StringFormat] = "\00311", - [Interpolation] = "\0037", + [Keyword] = "\00315", + [Macro] = "\0033", + [Comment] = "\0032", + [String] = "\00310", + [Format] = "\00311", + [Subst] = "\0037", }; static void ircHeader(const char *opts[]) { @@ -174,12 +174,12 @@ static void htmlEscape(const char *text) { } static const char *Styles[ClassCap] = { - [Keyword] = "color: dimgray;", - [Macro] = "color: green;", - [Comment] = "color: navy;", - [String] = "color: teal;", - [StringFormat] = "color: teal; font-weight: bold;", - [Interpolation] = "color: olive;", + [Keyword] = "color: dimgray;", + [Macro] = "color: green;", + [Comment] = "color: navy;", + [String] = "color: teal;", + [Format] = "color: teal; font-weight: bold;", + [Subst] = "color: olive;", }; static void styleTabSize(const char *tab) { @@ -210,7 +210,7 @@ static void htmlHeader(const char *opts[]) { } for (enum Class class = 0; class < ClassCap; ++class) { if (!Styles[class]) continue; - printf(".hilex.%s { %s }\n", Class[class], Styles[class]); + printf("pre.hilex .%.2s { %s }\n", Class[class], Styles[class]); } printf("</style>\n"); } @@ -235,7 +235,7 @@ static void htmlFormat(const char *opts[], enum Class class, const char *text) { if (opts[Inline]) { printf("<span style=\"%s\">", Styles[class] ? Styles[class] : ""); } else { - printf("<span class=\"hilex %s\">", Class[class]); + printf("<span class=\"%.2s\">", Class[class]); } htmlEscape(text); printf("</span>"); @@ -247,7 +247,7 @@ static void htmlFormat(const char *opts[], enum Class class, const char *text) { static const struct Formatter { const char *name; Header *header; - Format *format; + Output *format; Header *footer; } Formatters[] = { { "ansi", NULL, ansiFormat, NULL }, diff --git a/bin/hilex.h b/bin/hilex.h index 2a8d4ec0..2c080e20 100644 --- a/bin/hilex.h +++ b/bin/hilex.h @@ -22,13 +22,13 @@ X(Operator) \ X(Number) \ X(Keyword) \ - X(Identifier) \ + X(Ident) \ X(Macro) \ X(Comment) \ X(String) \ - X(StringEscape) \ - X(StringFormat) \ - X(Interpolation) + X(Escape) \ + X(Format) \ + X(Subst) enum Class { #define X(class) class, diff --git a/bin/html.sh b/bin/html.sh index c2ad7fa2..8214b8ff 100644 --- a/bin/html.sh +++ b/bin/html.sh @@ -62,12 +62,12 @@ a.tag:target { outline: none; } -.hilex.Keyword { color: var(--ansi7); } -.hilex.Macro { color: var(--ansi2); } -.hilex.Comment { color: var(--ansi4); } -.hilex.String { color: var(--ansi6); } -.hilex.StringFormat { color: var(--ansi14); } -.hilex.Interpolation { color: var(--ansi1); } +pre .Ke { color: var(--ansi7); } +pre .Ma { color: var(--ansi2); } +pre .Co { color: var(--ansi4); } +pre .St { color: var(--ansi6); } +pre .Fo { color: var(--ansi14); } +pre .Su { color: var(--ansi1); } </style> EOF diff --git a/bin/make.l b/bin/make.l index e7f3def5..d8c7071f 100644 --- a/bin/make.l +++ b/bin/make.l @@ -22,7 +22,7 @@ %} %s Assign -%x Interp Shell +%x Variable Shell ident [._[:alnum:]]+ assign [+?:!]?= @@ -55,7 +55,7 @@ operator [:!]|:: } ^{ident}/[[:blank:]]*{assign} { - return Identifier; + return Ident; } {assign} { @@ -73,24 +73,24 @@ operator [:!]|:: ^"-"?include { return Macro; } -{target} { return Identifier; } +{target} { return Ident; } "#"([^\\\n]|"\\"[^\n]|"\\\n")* { return Comment; } <*>{ "$"("{"|"(") { depth++; - BEGIN(Interp); - return Interpolation; + BEGIN(Variable); + return Subst; } - "$". { return Interpolation; } + "$". { return Subst; } } -<Interp>{ +<Variable>{ "}"|")" { if (!--depth) BEGIN(pop); - return Interpolation; + return Subst; } - [^${}()]+ { return Interpolation; } + [^${}()]+ { return Subst; } } .|\n { return Normal; } diff --git a/bin/man1/hilex.1 b/bin/man1/hilex.1 index aec57860..b742b063 100644 --- a/bin/man1/hilex.1 +++ b/bin/man1/hilex.1 @@ -1,4 +1,4 @@ -.Dd January 12, 2021 +.Dd January 13, 2021 .Dt HILEX 1 .Os . @@ -68,21 +68,31 @@ Output ANSI terminal control sequences. .It Cm html Output HTML .Sy span -elements. -Each element has the classes -.Sy hilex -and one of the following: -.Sy Operator , -.Sy Number , -.Sy Keyword , -.Sy Identifier , -.Sy Macro , -.Sy Comment , -.Sy String , -.Sy StringEscape , -.Sy StringFormat , -.Sy Interpolation . -. +elements +with the following classes: +.Pp +.Bl -hang -width "\&Op" -compact +.It Sy \&Op +operators +.It Sy \&Nu +numbers +.It Sy \&Ke +keywords +.It Sy \&Id +identifiers +.It Sy \&Ma +macros +.It Sy \&Co +comments +.It Sy \&St +strings +.It Sy \&Es +character escapes +.It Sy \&Fo +format strings +.It Sy \&Su +variable substitutions +.El .Pp The options are as follows: .Bl -tag -width "title=..." |