c_parser.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:rvmi-rekall 作者: fireeye 项目源码 文件源码
def _type_instance(self):
        """A type declaration.

        The modifiers of a typedef:
                struct s *P[];
                         ^^^^<-    The type instance.
        """
        type_instance = (
            # Function pointer     (*f)(int foobar)
            pyparsing.ZeroOrMore(_STAR)
            + _OPEN_PARENTHESIS
            + pyparsing.Optional(_STAR("function_pointer"))
            + self._identifier()("type_instance_name")
            + _CLOSE_PARENTHESIS
            + parsers.anything_in_parentheses()("function_args")
        ) | (
            # Function object  f(foo bar *)
            pyparsing.ZeroOrMore(_STAR)
            + self._identifier()("type_instance_name")
            + parsers.anything_in_parentheses()("function_args")
        ) | (
            # Simple form: *foo[10];
            pyparsing.ZeroOrMore(_STAR)("type_pointer")
            + self._identifier()("type_instance_name")

            # Possibly array: [] , [][]
            + pyparsing.ZeroOrMore(
                _OPEN_BRACKET
                + pyparsing.SkipTo(_CLOSE_BRACKET)(
                    "brackets_with_expression_inside*")
                + _CLOSE_BRACKET)

            # Bitfields:    int x: 7;
            + pyparsing.Optional(
                _COLON
                + pyparsing.SkipTo(
                    _SEMICOLON | _COMMA)("bitfield")
            )
        )

        return pyparsing.Group(
            type_instance
            + self._maybe_attributes()
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号