Original Parser

version 1 by Ron Newcomb

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Scope Level 0

    [The two ways of starting up the scope machinery other than via the parser
    code above.]

    To decide if (scopee - an object) is within the scope of (scoper - an object) (this is TestScope): [this would be a fine relation]
        [ save these values ]
        let x be parser one;
        let y be parser two;
        let a be the person asked;
        let al be the actor's scopewise location;
        let sr be the reason for deciding scope;
        ;
        now parser one is the scopee;
        now parser two is false;
        now the reason for deciding scope is because we're testing scope;
        if the scoper is nothing, now the person asked is the player;
        otherwise now the person asked is the scoper;
        now the actor's scopewise location is the scope ceiling of the person asked;
        search the scope of the actor's scopewise location and the person asked under 'something';
        let the returned truth state be parser two;
        ;
        [ restore those values ]
        now the reason for deciding scope is sr;
        now the actor's scopewise location is al;
        now the person asked is a;
        now parser two is y;
        now parser one is x;
        decide on the returned truth state.

    [ TestScope obj act a al sr x y;
    x = parser_one; y = parser_two;
    parser_one = obj; parser_two = 0; a = actor; al = actors_location;
    sr = scope_reason; scope_reason = TESTSCOPE_REASON;
    if (act == 0) actor = player; else actor = act;
    actors_location = ScopeCeiling(actor);
    SearchScope(actors_location, actor, 0); scope_reason = sr; actor = a;
    actors_location = al; parser_one = x; x = parser_two; parser_two = y;
    return x;
    ]

    To apply (desired routine - an object based rule producing nothing) to everything within scope of (scoper - an object) (this is LoopOverScope):
        [ save these values ]
        let x be the parser callback;
        let y be parser two;
        let a be the person asked;
        let al be the actor's scopewise location;
        ;
        now the parser callback is the desired routine;
        if the scoper is nothing, now the person asked is the player;
        otherwise now the person asked is the scoper;
        now the actor's scopewise location is the scope ceiling of the person asked;
        now the reason for deciding scope is because we're looping over scope;
        search the scope of the actor's scopewise location and the person asked under 'something';
        ;
        [ restore those values ]
        now the actor's scopewise location is al;
        now the person asked is a;
        now parser two is y;
        now the parser callback is x.
        

    [ LoopOverScope routine act x y a al;
    x = parser_one; y = scope_reason; a = actor; al = actors_location;
    parser_one = routine;
    if (act == 0) actor = player; else actor = act;
    actors_location = ScopeCeiling(actor);
    scope_reason = LOOPOVERSCOPE_REASON;
    SearchScope(actors_location, actor, 0);
    parser_one = x; scope_reason = y; actor = a; actors_location = al;
    ]