Coding the S Expression Parser

For simplicity, just return a boolean  indicating whether aor not a string generated from the auxiliary.

The input stream in part of the object and is not shown explicitly.

 

The actual code is in examples/SexpParser/SexpParser.java

boolean S()

  {

  if( next char is '(' )

    {

  //S '(' {S} ')'

    while( S() )

      {}

    if( next char is ')' )

      return true;

    else

      return false;

    }

  return A();

  }

boolean A()

  {

  if( next char is 'a' or 'b' or 'c' )

    return true;

  else

    return false;

  }

 

To Next Slide To Previous Slide To Contents