Exemplo n.º 1
0
    def read_dictionary(self):
        """Reads an IDL dictionary definition.

    Returns:
      A Dictionary object.
    """
        # The tokenizer attaches the doc to the next token, so the type's doc is
        # actually on the 'dictionary' token.
        dict_doc = self._reader.expect(IdlTokenType.DICTIONARY).doc
        name = self._reader.expect(IdlTokenType.IDENTIFIER).value

        attributes = []
        self._reader.expect(IdlTokenType.BEGIN_INTERFACE)
        while (self._reader.peek()
               and self._reader.peek().type != IdlTokenType.END_INTERFACE):
            attr_doc = self._reader.peek().doc
            t = self.read_type()
            attr_name = self._reader.expect(IdlTokenType.IDENTIFIER).value
            attributes.append(
                types.Attribute(name=attr_name,
                                type=t,
                                doc=attr_doc,
                                debug=None,
                                docDebug=None))
            self._reader.expect(IdlTokenType.SEMI_COLON)

        self._reader.expect(IdlTokenType.END_INTERFACE)
        self._reader.expect(IdlTokenType.SEMI_COLON)
        return types.Dictionary(name=name,
                                attributes=attributes,
                                doc=dict_doc,
                                debug=None,
                                docDebug=None)
 def p_Dictionary_error(self, p):
     r"""Dictionary : MaybeDoc DICTIONARY IDENTIFIER '{' error '}' ';'"""
     return types.Dictionary(name=p[3],
                             attributes=[],
                             doc=p[1],
                             debug=None,
                             docDebug=None)
Exemplo n.º 3
0
 def p_Dictionary(self, p):
   r"""Dictionary : MaybeDoc DICTIONARY IDENTIFIER '{' DictionaryMembers '}' ';'"""
   # TODO: Add support for inheritance.
   self._check_options(p, 2, Features.DICTIONARY)
   debug = self._get_debug(p, 2)
   docDebug = self._get_debug(p, 1) if p[1] else None
   return types.Dictionary(
       name=p[3], attributes=p[5], doc=p[1], debug=debug, docDebug=docDebug)