Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 2 - From the Definitions i6t File

    A token type is a kind of value. Some token types are
        '<grammar token>', [ then tdata is a Grammar Token. ]
        '<understood word>', [ then tdata is a Understood Word, but it isn't interesting -- like the "to" in GIVE X TO Y ]
        '<description of values>', [ then tdata is a noun=Routine matching most anything: KOVs, description of objects, a kind like direction, etc. ]
        '<adjective>', [ then tdata is an either/or property: edible? lit? open? I7 just uses the above for this, but it works if exposed. ]
        'any <description of objects>', [ then tdata is a scope=Routine that adds objects to Scope: 'any room', 'any person', etc. 16.7. Understanding any, understanding rooms]
        '<understand token>'. [ then tdata is a <Routine> that returns GPR_FAIL, GPR_PREPOSITION, etc.]
    [To decide what token type is
        the end of line token type: (- ENDIT_TOKEN -). ]

    To decide which token type is the first slashed synonym: (- $20 -).
    [To decide which number is a middle slashed synonym: (- $30 -). ]
    To decide which token type is the last slashed synonym: (- $10 -).

    [See chapter 16.4, "Standard Tokens of Grammar" in _Writing with Inform_. ]
    A grammar token is a kind of value. To decide which grammar token is
        'something': [0] (- NOUN_TOKEN -). Some [more] grammar tokens are
        'something preferably held', [held token]
        'things', [multi token]
        'things preferably held', [multi-held token]
        'other things', [multi-except token] [ anything except the second noun ]
        'things inside', [multi-inside token]
        'someone', [ synonymously anyone, somebody, anybody but NOT 'a person' ]
        'understood word', [ used for TEST and SHOWME testing commands ]
        'number',
        'text'. [ The Topic Understood ]
    To decide which grammar token is
        the end of line token: [15] (- ENDIT_TOKEN -).

    A descriptor property is a kind of value. Some descriptor properties are the invalid-descriptor-property.
    To decide which descriptor property is like 'MY\THESE\HIS' etc: (-POSSESS_PK-).
    To decide which descriptor property is like 'THE': (-DEFART_PK-) .
    To decide which descriptor property is like 'A\AN\SOME': (-INDEFART_PK-).
    To decide which descriptor property is 'LIT\LIGHTED': (- light -).
    To decide which descriptor property is 'UNLIT': (- (-light) -).

    A run-time problem is a kind of value. Some run-time problems are the backdrops in regions only run-time problem.
    To decide which run-time problem is the cannot say invalid snippets run-time problem: (- RTP_SAYINVALIDSNIPPET -).
    To decide which run-time problem is the cannot splice invalid snippets run-time problem: (- RTP_SPLICEINVALIDSNIPPET -).
    To decide which run-time problem is the cannot include invalid snippets run-time problem: (- RTP_INCLUDEINVALIDSNIPPET -).
    To decide which run-time problem is the bad topic run-time problem: (- RTP_BADTOPIC -).

    A parser result is a kind of value. Some parser results are
        parse succeeds as the-K-understood, [1]
        the resulting objects. [2]
    To decide which parser result is
        parse fails: [-1] (- GPR_FAIL -).
    To decide which parser result is
        parse succeeds: [0] (- GPR_PREPOSITION -).
    To decide which parser result is
        reparsing: (- GPR_REPARSE -).
    To decide which parser result is
        reparsing as (gt - grammar token): [-256+...] (- (GPR_NOUN + {gt}) -).

    To decide which parser result is (obj - an object) as a parser result: (- {obj} -).
    To decide which object is (pr - a parser result) as an object: (- {pr} -).
    [To decide if (pr - a parser result) is at least (pr2 - a parser result): (- ({pr} >= {pr2}) -).]
    To decide which grammar token is (pr - a parser result) as a grammar token: (- ({pr} + 256) -).
    To decide which number is (pr - a parser result) as a number: (- {pr} -).
    To say (pr - a parser result):
        if pr is parse fails, say "parse fails";
        if pr is parse succeeds, say "parse succeeds";
        if pr is reparsing, say "reparsing";
        if pr is parse succeeds as the-K-understood, say "parse succeeds as the-K-understood";
        if pr is resulting objects, say "resulting objects";
        if pr as a number < -1, say "reparse as '[(pr as a number - 256) as a grammar token]'";
        if pr as a number > 2, say "parse succeeds as '[pr as an object]'";


    The pattern union is a kind of value. [ It combines objects, understood words, and 4 different KOV values. ]
    Some pattern unions are that special word. [1]
    To decide which pattern union is a bunch of objects: [0] (- MULTIPLE_OBJECT_PATTERN -).
    To decide which pattern union is the null pattern: [-1] (- PATTERN_NULL -).
    To decide which pattern union is noun domain's bunch of objects: (- 1 -).
    To decide which pattern union is the pattern matched successfully: (- 1 -).
    To decide which pattern union is noun domain's no match: (- 0 -).
    To decide which pattern union is the misunderstood command: (- REPARSE_CODE -).
    To decide if (n - a pattern union) is currently an object:
    (- (({n} > (+ that special word +)) && ({n} < (+ the misunderstood command +))) -).
    To decide if (n - a pattern union) is currently an understood word:
    (- ({n} >= (+ the misunderstood command +)) -).
    To decide what pattern union is (w - an understood word) as a pattern union: (- ((+ misunderstood command +) + VM_DictionaryAddressToNumber({w})) -).
    To decide what pattern union is (obj - an object) as a successful match: (- ({obj}) -).
    To decide what object is (n - a pattern union) as an object: (- ({n}) -).


    An UNDO reason is a kind of value. To decide which UNDO reason is
        UNDO's unsupported: (- 0 -). Some [more] UNDO reasons are
        no further saved state exists to return to,
        ready to UNDO, and
        UNDO succeeded.

    A scope reason is a kind of value. Some scope reasons are
        does this allow multiple objects, [ return a truth state ]
        please add eligible objects to scope, [ return whether or not these are the ONLY objects in scope ]
        please report the noun not making sense in this context, [or return -1 for the parser error activity to handle it ]
        the invalid scope reason,
        because we're looping over scope,
        because we're testing scope.
    To decide which scope reason is
        because we're parsing the predicate nouns: (- PARSING_REASON -).
    To decide which scope reason is
        because we're parsing the addressee: (- TALKING_REASON -).

    To say (r - a scope reason):
        if r is because we're parsing the predicate nouns:
            say "parsing the predicate nouns";
        otherwise if r is because we're parsing the addressee:
            say "parsing the addressee";
        otherwise:
            say r.

    A word usage is a kind of value. Some word usages are
        being a verb,
        being out of world,
        an invalid word usage,
        being plural.
    To decide what word usage is
        being a preposition: (- IS_PREPOSITION -).
    To decide what word usage is
        being a noun: (- IS_NOUN -).
    To decide what word usage is
        the unused usages: (- UNUSED_USAGES -).
    To decide what word usage is
        all possible grammatical cases: (- $$111111111111 -). [4095]

    To decide what word usage is the usages/usage of (w - an understood word):
    (- (({w})->#dict_par1) -).

    Include (-
    Constant IS_PREPOSITION = 8;
    Constant IS_NOUN = 128;
    Constant UNUSED_USAGES = $$01110000;
    -).

    A parser action is a kind of value. Some parser actions are parsing normally, identifying identical things, and identifying plurals. [ This is for the technically-sophisticated author's use only; the parser doesn't use this. See 25.22 "Understand Tokens" in Writing With Inform. Originally they were declared as fake-actions, but Inform 7 doesn't have those. So, I chose this. ]

    To decide which object is the used-up object: (- (-1) -). [ The parser formerly used an I6-only object called "InformParser" for one obscure case that only made debugging output slightly nicer. I removed it in favor of this object, which gets much more use elsewhere in the parser. ]