code: def language_from_str(language_def, metamodel):
      
  
      if type(language_def) is not text:
          raise TextXError("textX accepts only unicode strings.")
  
      if metamodel.debug:
          metamodel.dprint("*** PARSING LANGUAGE DEFINITION ***")
  
      # Check the cache for already conctructed textX parser
      if metamodel.debug in textX_parsers:
          parser = textX_parsers[metamodel.debug]
      else:
          # Create parser for TextX grammars using
          # the arpeggio grammar specified in this module
          parser = ParserPython(textx_model, comment_def=comment,
                                ignore_case=False,
                                reduce_tree=False,
                                memoization=metamodel.memoization,
                                debug=metamodel.debug,
                                file=metamodel.file)
  
          # Cache it for subsequent calls
          textX_parsers[metamodel.debug] = parser
  
      # Parse language description with textX parser
      try:
          parse_tree = parser.parse(language_def)
      except NoMatch as e:
          line, col = parser.pos_to_linecol(e.position)
          raise TextXSyntaxError(text(e), line, col)
  
      # Construct new parser and meta-model based on the given language
      # description.
      lang_parser = visit_parse_tree(parse_tree,
                                     TextXVisitor(parser, metamodel))
  
      # Meta-model is constructed. Validate its semantics.
      metamodel.validate()
  
      # Here we connect meta-model and language parser for convenience.
      lang_parser.metamodel = metamodel
      metamodel._parser_blueprint = lang_parser
  
      if metamodel.debug:
          # Create dot file for debuging purposes
          PMDOTExporter().exportFile(
              lang_parser.parser_model,
              "{}_parser_model.dot".format(metamodel.rootcls.__name__))
  
      return lang_parser
docs: Constructs parser and initializes metamodel from language description
      given in textX language.
  
      Args:
          language_def (str): A language description in textX.
          metamodel (TextXMetaModel): A metamodel to initialize.
  
      Returns:
          Parser for the new language.