Running multiple parsers on an input file¶
Universal-ctags provides parser developers ways to run multiple parsers for an input file.
This subsection explains some examples of running multiple parsers. An example includes cases people wants to run multiple parsers on an input file, parser APIs used in the implementation.
There are two ways to combine parsers: guest/host and sub/base.
Applying a parser to specified areas of input file (guest/host)¶
guest/host combination considers the case that an input file has areas written in languages different from the language for the input file.
host parser parses the input file and detects the areas. guest parsers parses the areas.
guest parsers are run only when –extras=+g is given. If –fields=+E is given, all tags generated by a guest parser is marked guest in their extras: fields.
Examples of guest/host combinations¶
C/Yacc parser combination¶
Similar case is found in YACC input. A yacc file has some areas written in C. Universal-ctags has both YACC and C parsers. You may want to run C parser for the areas from YACC parser.
Here YACC parser is a host parser. C parser is a guest parser. See promise API and parsers/yacc.c.
Pod/Perl parser combination¶
Pod (Plain Old Documentation) is a language for documentation. Not only the language can be used in stand alone file but also it can be used inside a perl script.
Universal-ctags has both parsers for Perl and Pod. The perl parser recognizes the area where Pod document is embedded and runs Pod parser as a guest parser on the area.