code: def build_parser(output_dir=dir_latex_antlr):
      check_antlr_version()
  
      debug("Updating ANTLR-generated code in {}".format(output_dir))
  
      if not os.path.exists(output_dir):
          os.makedirs(output_dir)
  
      with open(os.path.join(output_dir, "__init__.py"), "w+") as fp:
          fp.write(header)
  
      args = [
          "antlr4",
          grammar_file,
          "-o",
          output_dir,
          # for now, not generating these as latex2sympy did not use them
          "-no-visitor",
          "-no-listener",
      ]
  
      debug("Running code generation...\n\t$ {}".format(" ".join(args)))
      subprocess.check_output(args, cwd=output_dir)
  
      debug(
          "Applying headers, removing unnecessary files and renaming..."
      )
      # Handle case insensitive file systems. If the files are already
      # generated, they will be written to latex* but LaTeX*.* won't match them.
      for path in glob.glob(
          os.path.join(output_dir, "LaTeX*.*")
      ) or glob.glob(os.path.join(output_dir, "latex*.*")):
          # Remove files ending in .interp or .tokens as they are not needed.
          if not path.endswith(".py"):
              os.unlink(path)
              continue
  
          new_path = os.path.join(
              output_dir, os.path.basename(path).lower()
          )
          with open(path, "r") as f:
              lines = [line.rstrip() + "\n" for line in f.readlines()]
  
          os.unlink(path)
  
          with open(new_path, "w") as out_file:
              offset = 0
              while lines[offset].startswith("#"):
                  offset += 1
              out_file.write(header)
              out_file.writelines(lines[offset:])
  
          debug("\t{}".format(new_path))
  
      return True
  
imports: import os
  import subprocess
  import glob
  from sympy.utilities.misc import debug
label_desc: Use image node_id 2 for calling a global function with example usage: build_parser(output_dir) and returns: True