Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Parser Tracing and Statistics

This example will demonstrate basic parser tracing, the primary debugging tool. When a parser unexpectedly fails it could be that the grammar is in error or that input string is an invalid grammar phase or both. The best way to find out what is going on is to examine each step the parser takes. The default trace will show every step, but it is highly configurable to eliminate unneeded steps and zero in on the error.

APG also has detailed statistics gathering capabilities. Parser, memory and vector statistics are available.

Note that trace and statistics have display functions and therefore require <stdio.h>. The APG library specifically excludes all I/O functions except when trace and/or statistics are enabled.

  • application code must include header files:
    • ../../utilities/utilities.h
    • ../../api/api.h (for parser generation)
  • application compilation must include source code from the directories:
    • ../../api
    • ../../library
    • ../../utilities
  • application compilation must define macros:
    • APG_TRACE
    • APG_STATS
    • APG_MEM_STATS
    • APG_VEC_STATS
    • APG_AST (required for API)

The compiled example will execute the following cases. Run the application with no arguments for application usage.

  • case 1: Display application information. (type names, type sizes and defined macros)
  • case 2: Illustrate default tracing with and without PPPT.
  • case 3: Generate a trace configuration file template.
  • case 4: Trace a restricted record range.
  • case 5: Trace rule names only.
  • case 6: Trace only specific rule names.
  • case 7: Parsing statistics, hit count vs alphabetical.
  • case 8: Parsing statistics, with and without PPPT.
  • case 9: Parsing statistics, cumulative for multiple parses.",
  • case 10: Illustrate memory statistics.
  • case 11: Illustrate vector statistics.
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.