Ferreteria/v0.6/sys/Parsing/v0

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | sys‎ | Parsing
Jump to navigation Jump to search
Ferreteria: Parsing system v0 (obsolete)

Terminology

An approximate breakdown (not entirely accurate);

  • `Lookup`: basically a string-to-string conversion function, where the input-to-output transformation depends on a known set of data
  • `Parser`: takes a string with marked sections and returns a set of objects that fully represent each section
  • `Replacer`: looks for matching pieces and, if/when found, replaces them with requested outputs
  • `Template`: a marked-up string, along with the marks it uses for designating sections

Lookup

Each lookup object has a set of data to draw from, and will transform each input into an output through reference to that data. The simplest version of this is just doing a key-value lookup in an array, but Lookup podling classes can also implement more complex expression-handling.

Parser

This was originally written for parsing templates. It iterates through a string with sections that are marked in certain ways, and returns a series of objects representing each section. The objects must all have the same interface, but do not have to be the same class -- which allows each section to be handled in different ways.

Replacer

This was originally written for the purpose of detecting known PHP error messages, and providing more context. Context could include things like replacing a plaintext classoid-name with a link to more information about that classoid, or doing additional checks when a particular error has a very common cause.