Recursive Descent, Tail Recursion, & the Dreaded Double Divide
by Truck Smith


Listing One

Lexor lexor( "18/6/3" );
int Factor() {
    int d = lexor.GetNumber();
}
int Term() {
    int t = Factor();
    if( lexor.CurrToken() == '/' ){
        lexor.MoveNext();
        int f = Term();
        t = t / f;
    }
   return t;
}

Listing Two

int Term() {
    int t = Factor();
    while( lexor.CurrToken() == '/' ){
        lexor.MoveNext();
        int f = Factor();
        t = t / f;
    }
    return t;
}




1


