@@ -480,6 +480,8 @@ static optionDescription LongOptionDescription [] = {
480480 {1 ,1 ," Output list of flags which can be used with --roledef option." },
481481 {1 ,0 ,"" },
482482 {1 ,0 ,"Miscellaneous Options" },
483+ {1 ,0 ," --describe-language=<language>" },
484+ {1 ,0 ," Print the various aspects of the parser implementing the language." },
483485 {1 ,0 ," --help" },
484486 {1 ,0 ," Print this option summary." },
485487 {1 ,0 ," -? Print this option summary." },
@@ -2306,6 +2308,107 @@ static void processListSubparsersOption (const char *const option CTAGS_ATTR_UNU
23062308 exit (0 );
23072309}
23082310
2311+ static void proecssDescribeLanguage (const char * const option ,
2312+ const char * const parameter )
2313+ {
2314+ /* Version, enable */
2315+ if (parameter == NULL || parameter [0 ] == '\0' )
2316+ error (FATAL , "No language given in \"--%s\" option" , option );
2317+
2318+
2319+ langType language = getNamedLanguage (parameter , 0 );
2320+ if (language == LANG_IGNORE )
2321+ error (FATAL , "Unknown language \"--%s\" in \"%s\"" , parameter , option );
2322+
2323+ initializeParser (language );
2324+
2325+ printf ("About %s language\n" , parameter );
2326+ puts ("=======================================================" );
2327+
2328+ printf ("enabled: %s\n" , isLanguageEnabled (language )? "yes" : "no" );
2329+ printf ("version: %u.%u\n" ,
2330+ getLanguageVersionCurrent (language ),
2331+ getLanguageVersionAge (language ));
2332+
2333+ puts ("" );
2334+ puts ("Mappings/patterns" );
2335+ puts ("-------------------------------------------------------" );
2336+ printLanguageMaps (language , LMAP_PATTERN |LMAP_NO_LANG_PREFIX ,
2337+ localOption .withListHeader , localOption .machinable ,
2338+ stdout );
2339+
2340+ puts ("" );
2341+ puts ("Mappings/extensions" );
2342+ puts ("-------------------------------------------------------" );
2343+ printLanguageMaps (language , LMAP_EXTENSION |LMAP_NO_LANG_PREFIX ,
2344+ localOption .withListHeader , localOption .machinable ,
2345+ stdout );
2346+
2347+ puts ("" );
2348+ puts ("Aliases" );
2349+ puts ("-------------------------------------------------------" );
2350+ printLanguageAliases (language ,
2351+ localOption .withListHeader , localOption .machinable , stdout );
2352+
2353+ puts ("" );
2354+ puts ("Kinds" );
2355+ puts ("-------------------------------------------------------" );
2356+
2357+ printLanguageKinds (language , true,
2358+ localOption .withListHeader , localOption .machinable , stdout );
2359+
2360+ puts ("" );
2361+ puts ("Roles" );
2362+ puts ("-------------------------------------------------------" );
2363+ printLanguageRoles (language , "*" ,
2364+ localOption .withListHeader ,
2365+ localOption .machinable ,
2366+ stdout );
2367+
2368+ puts ("" );
2369+ puts ("Fields" );
2370+ puts ("-------------------------------------------------------" );
2371+ {
2372+ writerCheckOptions (Option .fieldsReset );
2373+ struct colprintTable * table = fieldColprintTableNew ();
2374+ fieldColprintAddLanguageLines (table , language );
2375+ fieldColprintTablePrint (table , localOption .withListHeader , localOption .machinable , stdout );
2376+ colprintTableDelete (table );
2377+ }
2378+
2379+ puts ("" );
2380+ puts ("Extras" );
2381+ puts ("-------------------------------------------------------" );
2382+ {
2383+ struct colprintTable * table = xtagColprintTableNew ();
2384+ xtagColprintAddLanguageLines (table , language );
2385+ xtagColprintTablePrint (table , localOption .withListHeader , localOption .machinable , stdout );
2386+ colprintTableDelete (table );
2387+ }
2388+
2389+ puts ("" );
2390+ puts ("Parameters" );
2391+ puts ("-------------------------------------------------------" );
2392+ printLanguageParams (language ,
2393+ localOption .withListHeader , localOption .machinable ,
2394+ stdout );
2395+
2396+ puts ("" );
2397+ puts ("Sub parsers stacked on this parser" );
2398+ puts ("-------------------------------------------------------" );
2399+ printLanguageSubparsers (language ,
2400+ localOption .withListHeader , localOption .machinable ,
2401+ stdout );
2402+
2403+ puts ("" );
2404+ puts ("Implementation specific status" );
2405+ puts ("-------------------------------------------------------" );
2406+ printf ("allow null tags: %s\n" , doesLanguageAllowNullTag (language )? "yes" : "no" );
2407+
2408+ exit (0 );
2409+
2410+ }
2411+
23092412static void processListOperators (const char * const option CTAGS_ATTR_UNUSED ,
23102413 const char * const parameter )
23112414{
@@ -2864,6 +2967,7 @@ static void processDumpOptionsOption (const char *const option, const char *cons
28642967static void processDumpPreludeOption (const char * const option , const char * const parameter );
28652968
28662969static parametricOption ParametricOptions [] = {
2970+ { "describe-language" , proecssDescribeLanguage , true, STAGE_ANY },
28672971 { "etags-include" , processEtagsInclude , false, STAGE_ANY },
28682972 { "exclude" , processExcludeOption , false, STAGE_ANY },
28692973 { "exclude-exception" , processExcludeExceptionOption , false, STAGE_ANY },
0 commit comments