Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 14 - Typecasts

    [ Inform 7 is strongly-typed. Inform 6 is not. And the parser code likes to cram multiple kinds of things into the same number. This makes sense code-wise, but is a little difficult for the human to understand until they familiarize themselves with what's going on. Many odd-looking mathmatical operations and comparisons result from trying to pull apart disparate types. I try to name meaningfully what's going on. ]

    To decide if (prop - an understood word valued property) are a/an/-- invalid list/--: (- ({prop} < 1) -).
    To decide if (x - an understood word valued property) as a truth state: (- ({x} == -1) -).
    To decide if (v - a property) are currently a rule: (- ({v} >= 256) -).
    To decide which either/or property is (r - a rule producing a truth state) as an adjective: (- ({r} - 1) -).

    To decide what number is at (n - a number) position: (- {n} -). [ Syntactic sugar for dealing with indexes -- think of it as typecasting between cardinal and ordinal numbers. ]

    To decide what rule producing a truth state is (x - a grammar token) as a filter: (- ({x}) -).
    To decide what rule producing a truth state is (x - a grammar token) as an adjective filter: (- ({x} + 1) -).

    To decide which understood word is (gt - a grammar token) as an understood word: (- {gt} -).
    To decide what grammar token is (x - a number) as a grammar token: (- ({x}) -).
    To decide what number is (x - a grammar token) as a number: (- ({x}) -).
    To decide what number is (o - object) as a number: (- {o} -).

    To decide if (obj - an object) is currently an object: (- ({obj} ofclass Object) -).
    To decide if (obj - an object) is not currently a kind-of-value: (- ({obj} >= 2) -).