gbranden pushed a commit to branch master
in repository groff.
commit 9b93e1709c50956aacc4f35e201ed0b2607db7ac
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Nov 21 22:56:37 2025 -0600
[troff]: Improve diagnostics' token descriptions.
* src/roff/troff/input.cpp (token::description): Report the node type of
node tokens when describing them.
---
ChangeLog | 5 +++++
src/roff/troff/input.cpp | 18 +++++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index fdde7050a..3ee216948 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-11-21 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (token::description): Report the node
+ type of node tokens when describing them.
+
2025-11-21 G. Branden Robinson <[email protected]>
[troff]: Give node types self-reported type information
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 05a0bb08a..930a84566 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2920,7 +2920,23 @@ const char *token::description()
case TOKEN_NEWLINE:
return "a newline";
case TOKEN_NODE:
- return "a node";
+ // Ah, the joys of computational natural language grammar.
+ {
+ const char *ndtype = nd->type();
+ const char initial_letter = ndtype[0];
+ bool is_vowelly = false;
+ // I wonder if Kernighan thought that the absence of set types and
+ // an "in" operator was one of Pascal's great blunders.
+ if (('a' == initial_letter)
+ || ('e' == initial_letter)
+ || ('i' == initial_letter)
+ || ('o' == initial_letter)
+ || ('u' == initial_letter))
+ is_vowelly = true;
+ (void) snprintf(buf, bufsz, "a%s %s token", is_vowelly ? "n" : "",
+ ndtype);
+ return buf;
+ }
case TOKEN_INDEXED_CHAR:
(void) snprintf(buf, maxstr, "indexed character %d",
character_index());
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit