# Extending ctags with a parser written in C

This chapter describes how to add a parser in C and the internal API of Universal Ctags.

Before you start writing a parser in C, consider using optlib parser. Universal Ctags extends the functionality so extensively that it can implement most of functionality for the parser. See ctags-optlib(7) and Extending ctags with Regex parser (optlib) for details.

optlib parser is also suitable for prototyping of a parser in C.

- Writing a parser in C
  - Registering a parser
  - Reading input file stream
  - Parsing
  - Adding a tag to the tag file
  - Adding the parser to `ctags`
  - Misc.
- Input text stream
  - inputFile type and the functions of input group
  - The functions of bypass group
  - The functions of raw group
  - Escaping and unescaping input fields
- Output tag stream
  - cork API
    - Background and Idea
    - How to use
    - Automatic full qualified tag generation
    - symbol table API
- tokenInfo API
- Multiple parsers
  - Guest parser (promise API)
    - Background and Idea
    - Usage
    - Internal design
  - API for subparser
    - Outline
    - Fields of `subparser` type
    - Extending `subparser` type
    - Making a tag in a subparser
    - Calling methods of subparsers from a base parser
    - Registering a subparser to its base parser
    - Scheduling running the base parser
- PackCC compiler-compiler
- Null tags
- Automatic parser guessing (TBW)
- Managing regular expression parsers (TBW)
- Ghost kind in regex parser (TBW)