Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next

  • Chapter - DoScopeAction

    [Level 4. This is where we take whatever action is to be performed as the
    ``visit'' to each scoped object, and it's the bottom at last of the scope

    To do scope action on (item - an object) (this is DoScopeAction):
        if trace 6, say "[bracket]DSA on [the item] with reason = [the reason for deciding scope as a debugging number] p1 = [parser one as a debugging number] p2 = [parser two as a debugging number][close bracket][line break]";
        save parser one;
        save the reason for deciding scope;
        if the reason for deciding scope is because we're testing scope:
            if the item is parser one, now parser two is true;
        otherwise if the reason for deciding scope is because we're looping over scope:
            if the parser callback is currently a rule, consider the parser callback for the item directly;
        otherwise: [ we're parsing for nouns or an addressee ]
            match text against the item;
        restore the reason for deciding scope;
        restore parser one.

    [ DoScopeAction item;

    #Ifdef DEBUG;
    if (parser_trace >= 6)
    print "[DSA on ", (the) item, " with reason = ", scope_reason,
    " p1 = ", parser_one, " p2 = ", parser_two, "]^";
    #Endif; ! DEBUG

    @push parser_one; @push scope_reason;

        switch(scope_reason) {
            TESTSCOPE_REASON: if (item == parser_one) parser_two = 1;
            LOOPOVERSCOPE_REASON: if (parser_one ofclass Routine) indirect(parser_one, item);
            PARSING_REASON, TALKING_REASON: MatchTextAgainstObject(item);

    @pull scope_reason; @pull parser_one;