Cross reference resolving for parser model.
16409
def second_textx_model(self, model_parser):
        """"""

        if self.grammar_parser.debug:
            self.grammar_parser.dprint("RESOLVING MODEL PARSER: second_pass")

        self._resolve_rule_refs(self.grammar_parser, model_parser)
        self._determine_rule_types(model_parser.metamodel)
        self._resolve_cls_refs(self.grammar_parser, model_parser)

        return model_parser
618591
def parse_value_reference(parser, event, node): #pylint: disable=unused-argument

    

    (next_event, next_node) = six.next(parser)

    # TODO 2/16 KS: Functions below do not exist: i.e. class stuff broken:
    #               parse_classpath, parse_localclasspath, parse_classname.

    if _is_start(next_event, next_node, 'CLASSPATH'):
        result = parse_classpath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'LOCALCLASSPATH'):
        result = parse_localclasspath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'CLASSNAME'):
        result = parse_classname(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'INSTANCEPATH'):
        result = parse_instancepath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'LOCALINSTANCEPATH'):
        result = parse_localinstancepath(parser, next_event, next_node)

    elif _is_start(next_event, next_node, 'INSTANCENAME'):
        result = parse_instancename(parser, next_event, next_node)

    else:
        raise ParseError('Expecting (CLASSPATH | LOCALCLASSPATH | CLASSNAME '
                         '| INSTANCEPATH | LOCALINSTANCEPATH | INSTANCENAME)')

    _get_end_event(parser, 'VALUE.REFERENCE')

    return result
840423
def _parseRelocations(self, sections):
        """"""
        for section in sections:
            if section.header.sh_link != SHN.UNDEF and section.header.sh_type in (SHT.REL, SHT.RELA):
                symbols = sections[section.header.sh_link].symbols
                relocations = self.__parseRelocationEntries(section, symbols)
                section.relocations = relocations
77238
private ParseTree parseLogicalOR(Expression expressionIn) {
    SourcePosition start = getTreeStartLocation();
    ParseTree left = parseLogicalAND(expressionIn);
    while (peek(TokenType.OR)) {
      Token operator = eat(TokenType.OR);
      ParseTree right = parseLogicalAND(expressionIn);
      left = new BinaryOperatorTree(getTreeLocation(start), left, operator, right);
    }
    return left;
  }
807075
def get_parser(cls):
        """"""
        organizer = cls()
        organizer.setup_parser()
        organizer._finish_parser()
        return organizer.parser
692010
def __get_calls_from_parser(proxy_parser, real_parser):
    
    __parsers[proxy_parser] = real_parser
    for method, safe, args, kwargs, proxy_subparser in proxy_parser.calls:
        args = (__proxy_to_real_parser(v) for v in args)
        kwargs = {k: __proxy_to_real_parser(v) for k, v in kwargs.items()}
        real_subparser = getattr(real_parser, method)(*args, **kwargs)
        if real_subparser is not None:
            __get_calls_from_parser(proxy_subparser, real_subparser)
426358
def parse(self, parser, xml):
        """"""
        #We can only process references if the XML tag has inner-XML
        if xml.text is not None:
            matches = parser.RE_REFS.finditer(xml.text)
            if matches:
                for match in matches:
                    #Handle "special" references to this.name and param.name here.
                    self.references.append(match.group("reference"))

        #We also need to get all the XML attributes into the element
        for key in list(xml.keys()):
            self.attributes[key] = xml.get(key)
433684
def parse(cls, parser, text, pos):
        """"""
        try:
            parser._parsing_parenthesized_simple_values_expression = True
            remaining_text, recognized_tokens = parser.parse(text, cls.grammar)
            return remaining_text, recognized_tokens
        except SyntaxError as e:
            return text, e
        finally:
            parser._parsing_parenthesized_simple_values_expression = False
350035
def resolve_circular_references(self) -> None:
        
        circulars = self.circular_references()
        for c in circulars:
            fwdref = JSGForwardRef(c)
            self.grammarelts[fwdref.label] = fwdref
            self.forward_refs[c] = fwdref.label
437928
public Source resolve( String pHref, String pBase )
        throws TransformerException
    {

        URL url = null;
        
        final Source source = resolver.resolve( pHref, pBase );
        
        if ( source != null )
        {
            if ( xincludeAware )
            {
                /*
                 * Avoid risky cast use correct resolved systemid
                 * to configure a xinclude aware source. 
                 */
                try
                {
                    url = new URI( source.getSystemId() ).toURL();
                }
                catch ( Exception e )
                {
                    throw new TransformerException( e );
                }
            }
            else
            {
                return source;
            }
        }

        if ( null == url )
        {
            url = resolve( pHref );     //probably should call new method resolve(String,URI) but left alone for legacy reasons.
        }

        if ( url != null )
        {
            try
            {
                return asSaxSource( asInputSource( url ) );
            }
            catch ( IOException e )
            {
                throw new TransformerException( e );
            }
            catch ( SAXException e )
            {
                throw new TransformerException( e );
            }
            catch ( ParserConfigurationException e )
            {
                throw new TransformerException( e );
            }
        }
        return null;
    }
349078
def parse_property_reference(parser, event, node): #pylint: disable=unused-argument
    

    name = _get_required_attribute(node, 'NAME')

    class_origin = _get_attribute(node, 'CLASSORIGIN')
    propagated = _get_attribute(node, 'PROPAGATED')

    qualifiers = []
    value = None

    (next_event, next_node) = six.next(parser)

    if _is_start(next_event, next_node, 'QUALIFIER'):

        qualifiers.append(parse_qualifier(parser, next_event, next_node))

        while 1:

            (next_event, next_node) = six.next(parser)

            if _is_start(next_event, next_node, 'VALUE.REFERENCE'):
                break

            if _is_start(next_event, next_node, 'QUALIFIER'):
                qualifiers.append(
                    parse_qualifier(parser, next_event, next_node))

            else:
                raise ParseError('Expecting QUALIFIER')

    if _is_start(next_event, next_node, 'VALUE.REFERENCE'):

        value = parse_value_reference(parser, next_event, next_node)
        (next_event, next_node) = six.next(parser)

    if not _is_end(next_event, next_node, 'PROPERTY.REFERENCE'):
        raise ParseError('Expecting end PROPERTY.REFERENCE')

    return CIMProperty(
        name,
        value,
        class_origin=class_origin,
        propagated=propagated,
        type='reference',
        qualifiers=dict([(x.name, x) for x in qualifiers]))
727037
def _initialize_references(model_class, name, bases, attrs):
    """"""
    model_class._references = {}
    h = {}
    deferred = []
    for k, v in attrs.iteritems():
        if isinstance(v, ReferenceField):
            model_class._references[k] = v
            v.name = v.name or k
            att = Attribute(name=v.attname)
            h[v.attname] = att
            setattr(model_class, v.attname, att)
            refd = _initialize_referenced(model_class, v)
            if refd:
                deferred.append(refd)
    attrs.update(h)
    return deferred
1012577
def parser():
    """"""
    query_parser = current_app.config['COLLECTIONS_QUERY_PARSER']
    if isinstance(query_parser, six.string_types):
        query_parser = import_string(query_parser)
        return query_parser
1008723
def structparser(token):
    """"""
    m = STRUCT_PACK_RE.match(token)
    if not m:
        return [token]
    else:
        endian = m.group('endian')
        if endian is None:
            return [token]
        # Split the format string into a list of 'q', '4h' etc.
        formatlist = re.findall(STRUCT_SPLIT_RE, m.group('fmt'))
        # Now deal with mulitiplicative factors, 4h -> hhhh etc.
        fmt = ''.join([f[-1] * int(f[:-1]) if len(f) != 1 else
                       f for f in formatlist])
        if endian == '@':
            # Native endianness
            if byteorder == 'little':
                endian = '<'
            else:
                assert byteorder == 'big'
                endian = '>'
        if endian == '<':
            tokens = [REPLACEMENTS_LE[c] for c in fmt]
        else:
            assert endian == '>'
            tokens = [REPLACEMENTS_BE[c] for c in fmt]
    return tokens
135638
def generate_supplied_intersect_subparser(subparsers):
    """"""
    parser = subparsers.add_parser(
        'sintersect', description=constants.SUPPLIED_INTERSECT_DESCRIPTION,
        epilog=constants.SUPPLIED_INTERSECT_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.SUPPLIED_INTERSECT_HELP)
    parser.set_defaults(func=supplied_intersect)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser, True)
    utils.add_supplied_query_arguments(parser)
454989
def resolve_column(self, ref):
    ""
    if isinstance(ref, sqparse2.AttrX):
      if ref.parent.name not in self:
        raise ScopeUnkError('unk table or table alias', ref.parent.name)
      return ref.parent.name, ref.attr.name
    elif isinstance(ref, sqparse2.NameX):
      matches = set()
      for name, target in self.names.items():
        if isinstance(target, SyntheticTable):
          if ref.name in target.columns(self):
            matches.add(name)
        elif isinstance(target, table.Table):
          try: target.get_column(ref.name)
          except KeyError: pass
          else: matches.add(name)
        else:
          raise TypeError('expected SyntheticTable', type(target), target)
      if not matches: raise ScopeUnkError(ref)
      elif len(matches) > 1: raise ScopeCollisionError(matches, ref)
      else: return list(matches)[0], ref.name
    else:
      raise TypeError('unexpected', type(ref), ref)
597246
def parse_references(cls, filename):
        
        references = set()
        for line in open(filename):
            matched = cls.RE_REF.match(line)
            if matched:
                reference = matched.group('path')
                reference_base = os.path.splitext(reference)[0]
                references.add(reference_base)
        return references