code: def chk_statement(ctx, stmt, grammar, canonical=False):
      
      n = len(ctx.errors)
      if canonical == True:
          canspec = grammar
      else:
          canspec = []
      _chk_stmts(ctx, stmt.pos, [stmt], None, (grammar, canspec), canonical)
      return n == len(ctx.errors)
docs: Validate `stmt` according to `grammar`.
  
      Marks each statement in the hierearchy with stmt.is_grammatically_valid,
      which is a boolean.
  
      Return True if stmt is valid, False otherwise.