code: def test_syntax_error_for_string(self) -> None:
      grammar_source = """
          start: expr+ NEWLINE? ENDMARKER
          expr: NAME
          """
      test_source = r"""
          for text in ("a b 42 b a", "\u540d \u540d 42 \u540d \u540d"):
              try:
                  parse.parse_string(text, mode=0)
              except SyntaxError as e:
                  tb = traceback.format_exc()
              self.assertTrue('File "<string>", line 1' in tb)
              self.assertTrue(f"SyntaxError: invalid syntax" in tb)
          """
      self.run_test(grammar_source, test_source)
  
imports: import contextlib
  import subprocess
  import sysconfig
  import textwrap
  import unittest
  import os
  import shutil
  import tempfile
  from pathlib import Path
  from test import test_tools
  from test import support
  from test.support import os_helper, import_helper
  from test.support.script_helper import assert_python_ok
label_desc: Use image node_id 22 for calling the TestCParser obj's underlying member method code with example usage: obj.test_syntax_error_for_string() without return types