Ferreteria/v0.6/sys/Parsing

From Woozle Writes Code
Jump to navigation Jump to search
Ferreteria: Parsing system v2 (revision in progress)
earlier: v0, v1

About

The parsing system is built on a collection of relatively simple ideas, but keeping them organized so they work well together gets complicated quickly.

Terminology

  • Nucleus (aka "Parser"): has one Guide (template) and one Found (received) string
    • (roughly equivalent to old "Template")
    • ->Parse() breaks the Guide string up into objects (Codons) that fully represent each section, and matches up the variable ones with data in Found.
      • returns a Gene
      • ...which contains zero or more Codons
  • Gene: an array of Codon objects
  • Strand (not a clade; aka "template string"): a string formatted in a way that the Nucleus knows how to parse

Thinking

  • 2026-04-17 I think maybe Nucleus needs to be replaced by:
    • Enzyme to "copy" the Strand-template into a Gene
    • Ribsome to "link" the variables in the Gene with corresponding bits in the Found string
    • However: neither of these objects actually store anything. Couldn't they just be separate fx calls?
      • Do they even need to be fully separate from Gene? I guess it's still good to package these bits of functionality in their own class(es), since they get messy, but...
  • 2025-12-29 Some updated terminological thinks:
    • A codon is a fixed-length segment of a DNA strand. I'm using it for variable-length sequences that are handled differently. (This is probably a very bad metaphor.)
      • I first thought of using "gene" for segment-collections, but the analogy seemed only vaguely applicable and the word "gene" gets a bit overused as a metaphor. Decided to use it for a collection of codons. (Genetic biologists will probably hate me now.)
    • An enzyme and a ribosome are both molecular machines that handle DNA segments like data. Enzymes copy, ribosomes link pieces together. It's a crude fit, but maybe it'll do?
    • A cell's nucleus contains most of its DNA, so that seemed a reasonable name for a collection of codons. (Maybe I should have just called it "codons"...)
      • Decided to use nucleus to represent the top-level clade, fka "Parser".