Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
The Line Parsing Utilities

This example will demonstrate the construction and use of the line parsing utilities.

SABNF grammars and many other files used by parser applications are defined as "lines" of text or characters. Lines are typically ended with one or more of the ASCII control characters

  • 0x0A line feed
  • 0x0D carriage return
  • 0x0D 0x0A, carriage return, line feed pair

Parsing or separating the text into separate line and line ending data is needed in many APG applications and objects. The lines object provides a unified means for identifying separate lines and iterating over them.

Similarly, arrays of Unicode characters often need the same facility. The linesu object will do much the same for arrays of 32-bit Unicode code points as the lines object does for character strings.

Unicode recognizes the following line ending characters:

  • LF 0x0A Line Feed
  • VT 0x0B Vertical Tab
  • FF 0x0C Form Feed
  • CR 0x0D Carriage Return
  • CRLF 0x0D 0x0A Carriage Return followed by Line Feed
  • NEL 0x85 Next Line
  • LS 0x2028 Line Separator
  • PS 0x2029 Paragraph Separator

Application requirements.

  • application code must include header files:
    • ../../utilities/utilities.h
  • application compilation must include source code from the directories:
    • ../../library
    • ../../utilities
  • application compilation must define macros:
    • (none)

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 the use of the lines object for strings of characters.
  • case 3: Illustrate the use of the linesu object for arrays of 32-bit Unicode code points.
APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.