X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/af1f874c4c58d0bd8becd52c892d0b358d08736e..566e87bb15a98ed499e79b45f6c834ad0ffdc3b7:/src/parse.y diff --git a/src/parse.y b/src/parse.y index 6faf2d2..263129c 100644 --- a/src/parse.y +++ b/src/parse.y @@ -62,6 +62,7 @@ %code provides { void cdecl__free(struct cdecl *); int cdecl__yyparse(void *scanner, struct cdecl **out); +const char *cdecl__token_name(unsigned token); } %union { @@ -589,3 +590,18 @@ english_vla: T_IDENT | { ALLOC($$, sizeof ""); strcpy($$, ""); } + +%% + +/* + * Expose the token string table to the rest of the library, in order to + * produce strings that match parser keywords. + * + * In order for this to work properly, the Bison output must be postprocessed + * by fix-yytname.awk to remove pointless quotation marks from the keyword + * strings. + */ +const char *cdecl__token_name(unsigned token) +{ + return yytname[YYTRANSLATE(token)]; +}