procedure main()
   while writes(line := read()) do
      if line ? (X() & pos(0)) then write(" accepted")
      else write(" rejected")
end

procedure T()
   suspend ["T",E()] | ["T",E(),="*",T()]
end

procedure E()
   suspend ["E",=("x" | "y" | "z")] | ["E",="(",X(),=")"]
end

procedure X()
   suspend ["X",T()] | ["X",T(),="+",X()]
end
