- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是解析方面的新手,我正在尝试使用 Pycparser 来解析我的 c 文件,我按照说明预处理文件 gcc -E 然后我使用示例文件夹中的 using_gcc_E_libc.py 并传递我的文件,我得到了一些输出,但不确定 AST 是否是这样的?如果那是正确的 AST,我如何找到每个节点及其依赖项以及该节点的指针(位置)?
FileAST:
Typedef: size_t, [], ['typedef']
TypeDecl: size_t, []
IdentifierType: ['int']
Typedef: __builtin_va_list, [], ['typedef']
TypeDecl: __builtin_va_list, []
IdentifierType: ['int']
Typedef: __gnuc_va_list, [], ['typedef']
TypeDecl: __gnuc_va_list, []
IdentifierType: ['int']
Typedef: va_list, [], ['typedef']
TypeDecl: va_list, []
IdentifierType: ['int']
Typedef: __int8_t, [], ['typedef']
TypeDecl: __int8_t, []
IdentifierType: ['int']
Typedef: __uint8_t, [], ['typedef']
TypeDecl: __uint8_t, []
IdentifierType: ['int']
Typedef: __int16_t, [], ['typedef']
TypeDecl: __int16_t, []
IdentifierType: ['int']
Typedef: __uint16_t, [], ['typedef']
TypeDecl: __uint16_t, []
IdentifierType: ['int']
Typedef: __int_least16_t, [], ['typedef']
TypeDecl: __int_least16_t, []
IdentifierType: ['int']
Typedef: __uint_least16_t, [], ['typedef']
TypeDecl: __uint_least16_t, []
IdentifierType: ['int']
Typedef: __int32_t, [], ['typedef']
TypeDecl: __int32_t, []
IdentifierType: ['int']
Typedef: __uint32_t, [], ['typedef']
TypeDecl: __uint32_t, []
IdentifierType: ['int']
Typedef: __int64_t, [], ['typedef']
TypeDecl: __int64_t, []
IdentifierType: ['int']
Typedef: __uint64_t, [], ['typedef']
TypeDecl: __uint64_t, []
IdentifierType: ['int']
Typedef: __int_least32_t, [], ['typedef']
TypeDecl: __int_least32_t, []
IdentifierType: ['int']
Typedef: __uint_least32_t, [], ['typedef']
TypeDecl: __uint_least32_t, []
IdentifierType: ['int']
Typedef: __s8, [], ['typedef']
TypeDecl: __s8, []
IdentifierType: ['int']
Typedef: __u8, [], ['typedef']
TypeDecl: __u8, []
IdentifierType: ['int']
Typedef: __s16, [], ['typedef']
TypeDecl: __s16, []
IdentifierType: ['int']
Typedef: __u16, [], ['typedef']
TypeDecl: __u16, []
IdentifierType: ['int']
Typedef: __s32, [], ['typedef']
TypeDecl: __s32, []
IdentifierType: ['int']
Typedef: __u32, [], ['typedef']
TypeDecl: __u32, []
IdentifierType: ['int']
Typedef: __s64, [], ['typedef']
TypeDecl: __s64, []
IdentifierType: ['int']
Typedef: __u64, [], ['typedef']
TypeDecl: __u64, []
IdentifierType: ['int']
Typedef: _LOCK_T, [], ['typedef']
TypeDecl: _LOCK_T, []
IdentifierType: ['int']
Typedef: _LOCK_RECURSIVE_T, [], ['typedef']
TypeDecl: _LOCK_RECURSIVE_T, []
IdentifierType: ['int']
Typedef: _off_t, [], ['typedef']
TypeDecl: _off_t, []
IdentifierType: ['int']
Typedef: __dev_t, [], ['typedef']
TypeDecl: __dev_t, []
IdentifierType: ['int']
Typedef: __uid_t, [], ['typedef']
TypeDecl: __uid_t, []
IdentifierType: ['int']
Typedef: __gid_t, [], ['typedef']
TypeDecl: __gid_t, []
IdentifierType: ['int']
Typedef: _off64_t, [], ['typedef']
TypeDecl: _off64_t, []
IdentifierType: ['int']
Typedef: _fpos_t, [], ['typedef']
TypeDecl: _fpos_t, []
IdentifierType: ['int']
Typedef: _ssize_t, [], ['typedef']
TypeDecl: _ssize_t, []
IdentifierType: ['int']
Typedef: wint_t, [], ['typedef']
TypeDecl: wint_t, []
IdentifierType: ['int']
Typedef: _mbstate_t, [], ['typedef']
TypeDecl: _mbstate_t, []
IdentifierType: ['int']
Typedef: _flock_t, [], ['typedef']
TypeDecl: _flock_t, []
IdentifierType: ['int']
Typedef: _iconv_t, [], ['typedef']
TypeDecl: _iconv_t, []
IdentifierType: ['int']
Typedef: __ULong, [], ['typedef']
TypeDecl: __ULong, []
IdentifierType: ['int']
Typedef: __FILE, [], ['typedef']
TypeDecl: __FILE, []
IdentifierType: ['int']
Typedef: ptrdiff_t, [], ['typedef']
TypeDecl: ptrdiff_t, []
IdentifierType: ['int']
Typedef: wchar_t, [], ['typedef']
TypeDecl: wchar_t, []
IdentifierType: ['int']
Typedef: __off_t, [], ['typedef']
TypeDecl: __off_t, []
IdentifierType: ['int']
Typedef: __pid_t, [], ['typedef']
TypeDecl: __pid_t, []
IdentifierType: ['int']
Typedef: __loff_t, [], ['typedef']
TypeDecl: __loff_t, []
IdentifierType: ['int']
Typedef: u_char, [], ['typedef']
TypeDecl: u_char, []
IdentifierType: ['int']
Typedef: u_short, [], ['typedef']
TypeDecl: u_short, []
IdentifierType: ['int']
Typedef: u_int, [], ['typedef']
TypeDecl: u_int, []
IdentifierType: ['int']
Typedef: u_long, [], ['typedef']
TypeDecl: u_long, []
IdentifierType: ['int']
Typedef: ushort, [], ['typedef']
TypeDecl: ushort, []
IdentifierType: ['int']
Typedef: uint, [], ['typedef']
TypeDecl: uint, []
IdentifierType: ['int']
Typedef: clock_t, [], ['typedef']
TypeDecl: clock_t, []
IdentifierType: ['int']
Typedef: time_t, [], ['typedef']
TypeDecl: time_t, []
IdentifierType: ['int']
Typedef: daddr_t, [], ['typedef']
TypeDecl: daddr_t, []
IdentifierType: ['int']
Typedef: caddr_t, [], ['typedef']
TypeDecl: caddr_t, []
IdentifierType: ['int']
Typedef: ino_t, [], ['typedef']
TypeDecl: ino_t, []
IdentifierType: ['int']
Typedef: off_t, [], ['typedef']
TypeDecl: off_t, []
IdentifierType: ['int']
Typedef: dev_t, [], ['typedef']
TypeDecl: dev_t, []
IdentifierType: ['int']
Typedef: uid_t, [], ['typedef']
TypeDecl: uid_t, []
IdentifierType: ['int']
Typedef: gid_t, [], ['typedef']
TypeDecl: gid_t, []
IdentifierType: ['int']
Typedef: pid_t, [], ['typedef']
TypeDecl: pid_t, []
IdentifierType: ['int']
Typedef: key_t, [], ['typedef']
TypeDecl: key_t, []
IdentifierType: ['int']
Typedef: ssize_t, [], ['typedef']
TypeDecl: ssize_t, []
IdentifierType: ['int']
Typedef: mode_t, [], ['typedef']
TypeDecl: mode_t, []
IdentifierType: ['int']
Typedef: nlink_t, [], ['typedef']
TypeDecl: nlink_t, []
IdentifierType: ['int']
Typedef: fd_mask, [], ['typedef']
TypeDecl: fd_mask, []
IdentifierType: ['int']
Typedef: _types_fd_set, [], ['typedef']
TypeDecl: _types_fd_set, []
IdentifierType: ['int']
Typedef: clockid_t, [], ['typedef']
TypeDecl: clockid_t, []
IdentifierType: ['int']
Typedef: timer_t, [], ['typedef']
TypeDecl: timer_t, []
IdentifierType: ['int']
Typedef: useconds_t, [], ['typedef']
TypeDecl: useconds_t, []
IdentifierType: ['int']
Typedef: suseconds_t, [], ['typedef']
TypeDecl: suseconds_t, []
IdentifierType: ['int']
Typedef: FILE, [], ['typedef']
TypeDecl: FILE, []
IdentifierType: ['int']
Typedef: fpos_t, [], ['typedef']
TypeDecl: fpos_t, []
IdentifierType: ['int']
Typedef: cookie_read_function_t, [], ['typedef']
TypeDecl: cookie_read_function_t, []
IdentifierType: ['int']
Typedef: cookie_write_function_t, [], ['typedef']
TypeDecl: cookie_write_function_t, []
IdentifierType: ['int']
Typedef: cookie_seek_function_t, [], ['typedef']
TypeDecl: cookie_seek_function_t, []
IdentifierType: ['int']
Typedef: cookie_close_function_t, [], ['typedef']
TypeDecl: cookie_close_function_t, []
IdentifierType: ['int']
Typedef: cookie_io_functions_t, [], ['typedef']
TypeDecl: cookie_io_functions_t, []
IdentifierType: ['int']
Typedef: div_t, [], ['typedef']
TypeDecl: div_t, []
IdentifierType: ['int']
Typedef: ldiv_t, [], ['typedef']
TypeDecl: ldiv_t, []
IdentifierType: ['int']
Typedef: lldiv_t, [], ['typedef']
TypeDecl: lldiv_t, []
IdentifierType: ['int']
Typedef: sigset_t, [], ['typedef']
TypeDecl: sigset_t, []
IdentifierType: ['int']
Typedef: __sigset_t, [], ['typedef']
TypeDecl: __sigset_t, []
IdentifierType: ['int']
Typedef: _sig_func_ptr, [], ['typedef']
TypeDecl: _sig_func_ptr, []
IdentifierType: ['int']
Typedef: sig_atomic_t, [], ['typedef']
TypeDecl: sig_atomic_t, []
IdentifierType: ['int']
Typedef: __tzrule_type, [], ['typedef']
TypeDecl: __tzrule_type, []
IdentifierType: ['int']
Typedef: __tzinfo_type, [], ['typedef']
TypeDecl: __tzinfo_type, []
IdentifierType: ['int']
Typedef: mbstate_t, [], ['typedef']
TypeDecl: mbstate_t, []
IdentifierType: ['int']
Typedef: sem_t, [], ['typedef']
TypeDecl: sem_t, []
IdentifierType: ['int']
Typedef: pthread_t, [], ['typedef']
TypeDecl: pthread_t, []
IdentifierType: ['int']
Typedef: pthread_attr_t, [], ['typedef']
TypeDecl: pthread_attr_t, []
IdentifierType: ['int']
Typedef: pthread_mutex_t, [], ['typedef']
TypeDecl: pthread_mutex_t, []
IdentifierType: ['int']
Typedef: pthread_mutexattr_t, [], ['typedef']
TypeDecl: pthread_mutexattr_t, []
IdentifierType: ['int']
Typedef: pthread_cond_t, [], ['typedef']
TypeDecl: pthread_cond_t, []
IdentifierType: ['int']
Typedef: pthread_condattr_t, [], ['typedef']
TypeDecl: pthread_condattr_t, []
IdentifierType: ['int']
Typedef: pthread_key_t, [], ['typedef']
TypeDecl: pthread_key_t, []
IdentifierType: ['int']
Typedef: pthread_once_t, [], ['typedef']
TypeDecl: pthread_once_t, []
IdentifierType: ['int']
Typedef: pthread_rwlock_t, [], ['typedef']
TypeDecl: pthread_rwlock_t, []
IdentifierType: ['int']
Typedef: pthread_rwlockattr_t, [], ['typedef']
TypeDecl: pthread_rwlockattr_t, []
IdentifierType: ['int']
Typedef: pthread_spinlock_t, [], ['typedef']
TypeDecl: pthread_spinlock_t, []
IdentifierType: ['int']
Typedef: pthread_barrier_t, [], ['typedef']
TypeDecl: pthread_barrier_t, []
IdentifierType: ['int']
Typedef: pthread_barrierattr_t, [], ['typedef']
TypeDecl: pthread_barrierattr_t, []
IdentifierType: ['int']
Typedef: jmp_buf, [], ['typedef']
TypeDecl: jmp_buf, []
IdentifierType: ['int']
Typedef: rlim_t, [], ['typedef']
TypeDecl: rlim_t, []
IdentifierType: ['int']
Typedef: sa_family_t, [], ['typedef']
TypeDecl: sa_family_t, []
IdentifierType: ['int']
Typedef: sigjmp_buf, [], ['typedef']
TypeDecl: sigjmp_buf, []
IdentifierType: ['int']
Typedef: stack_t, [], ['typedef']
TypeDecl: stack_t, []
IdentifierType: ['int']
Typedef: siginfo_t, [], ['typedef']
TypeDecl: siginfo_t, []
IdentifierType: ['int']
Typedef: z_stream, [], ['typedef']
TypeDecl: z_stream, []
IdentifierType: ['int']
Typedef: int8_t, [], ['typedef']
TypeDecl: int8_t, []
IdentifierType: ['int']
Typedef: uint8_t, [], ['typedef']
TypeDecl: uint8_t, []
IdentifierType: ['int']
Typedef: int16_t, [], ['typedef']
TypeDecl: int16_t, []
IdentifierType: ['int']
Typedef: uint16_t, [], ['typedef']
TypeDecl: uint16_t, []
IdentifierType: ['int']
Typedef: int32_t, [], ['typedef']
TypeDecl: int32_t, []
IdentifierType: ['int']
Typedef: uint32_t, [], ['typedef']
TypeDecl: uint32_t, []
IdentifierType: ['int']
Typedef: int64_t, [], ['typedef']
TypeDecl: int64_t, []
IdentifierType: ['int']
Typedef: uint64_t, [], ['typedef']
TypeDecl: uint64_t, []
IdentifierType: ['int']
Typedef: int_least8_t, [], ['typedef']
TypeDecl: int_least8_t, []
IdentifierType: ['int']
Typedef: uint_least8_t, [], ['typedef']
TypeDecl: uint_least8_t, []
IdentifierType: ['int']
Typedef: int_least16_t, [], ['typedef']
TypeDecl: int_least16_t, []
IdentifierType: ['int']
Typedef: uint_least16_t, [], ['typedef']
TypeDecl: uint_least16_t, []
IdentifierType: ['int']
Typedef: int_least32_t, [], ['typedef']
TypeDecl: int_least32_t, []
IdentifierType: ['int']
Typedef: uint_least32_t, [], ['typedef']
TypeDecl: uint_least32_t, []
IdentifierType: ['int']
Typedef: int_least64_t, [], ['typedef']
TypeDecl: int_least64_t, []
IdentifierType: ['int']
Typedef: uint_least64_t, [], ['typedef']
TypeDecl: uint_least64_t, []
IdentifierType: ['int']
Typedef: int_fast8_t, [], ['typedef']
TypeDecl: int_fast8_t, []
IdentifierType: ['int']
Typedef: uint_fast8_t, [], ['typedef']
TypeDecl: uint_fast8_t, []
IdentifierType: ['int']
Typedef: int_fast16_t, [], ['typedef']
TypeDecl: int_fast16_t, []
IdentifierType: ['int']
Typedef: uint_fast16_t, [], ['typedef']
TypeDecl: uint_fast16_t, []
IdentifierType: ['int']
Typedef: int_fast32_t, [], ['typedef']
TypeDecl: int_fast32_t, []
IdentifierType: ['int']
Typedef: uint_fast32_t, [], ['typedef']
TypeDecl: uint_fast32_t, []
IdentifierType: ['int']
Typedef: int_fast64_t, [], ['typedef']
TypeDecl: int_fast64_t, []
IdentifierType: ['int']
Typedef: uint_fast64_t, [], ['typedef']
TypeDecl: uint_fast64_t, []
IdentifierType: ['int']
Typedef: intptr_t, [], ['typedef']
TypeDecl: intptr_t, []
IdentifierType: ['int']
Typedef: uintptr_t, [], ['typedef']
TypeDecl: uintptr_t, []
IdentifierType: ['int']
Typedef: intmax_t, [], ['typedef']
TypeDecl: intmax_t, []
IdentifierType: ['int']
Typedef: uintmax_t, [], ['typedef']
TypeDecl: uintmax_t, []
IdentifierType: ['int']
Typedef: bool, [], ['typedef']
TypeDecl: bool, []
IdentifierType: ['_Bool']
Typedef: MirEGLNativeWindowType, [], ['typedef']
PtrDecl: []
TypeDecl: MirEGLNativeWindowType, []
IdentifierType: ['void']
Typedef: MirEGLNativeDisplayType, [], ['typedef']
PtrDecl: []
TypeDecl: MirEGLNativeDisplayType, []
IdentifierType: ['void']
Typedef: MirConnection, [], ['typedef']
TypeDecl: MirConnection, []
Struct: MirConnection
Typedef: MirSurface, [], ['typedef']
TypeDecl: MirSurface, []
Struct: MirSurface
Typedef: MirSurfaceSpec, [], ['typedef']
TypeDecl: MirSurfaceSpec, []
Struct: MirSurfaceSpec
Typedef: MirScreencast, [], ['typedef']
TypeDecl: MirScreencast, []
Struct: MirScreencast
Typedef: MirPromptSession, [], ['typedef']
TypeDecl: MirPromptSession, []
Struct: MirPromptSession
Typedef: MirBufferStream, [], ['typedef']
TypeDecl: MirBufferStream, []
Struct: MirBufferStream
Typedef: MirPersistentId, [], ['typedef']
TypeDecl: MirPersistentId, []
Struct: MirPersistentId
Typedef: MirBlob, [], ['typedef']
TypeDecl: MirBlob, []
Struct: MirBlob
Typedef: MirDisplayConfig, [], ['typedef']
TypeDecl: MirDisplayConfig, []
Struct: MirDisplayConfig
Typedef: xcb_connection_t, [], ['typedef']
TypeDecl: xcb_connection_t, []
Struct: xcb_connection_t
Typedef: xcb_window_t, [], ['typedef']
TypeDecl: xcb_window_t, []
IdentifierType: ['uint32_t']
Typedef: xcb_visualid_t, [], ['typedef']
TypeDecl: xcb_visualid_t, []
IdentifierType: ['uint32_t']
FuncDef:
Decl: main, [], [], []
FuncDecl:
TypeDecl: main, []
IdentifierType: ['int']
Compound:
Decl: number1, [], [], []
TypeDecl: number1, []
IdentifierType: ['int']
Decl: number2, [], [], []
TypeDecl: number2, []
IdentifierType: ['int']
FuncCall:
ID: printf
ExprList:
Constant: string, "Enter two integers: "
FuncCall:
ID: scanf
ExprList:
Constant: string, "%d %d"
UnaryOp: &
ID: number1
UnaryOp: &
ID: number2
If:
BinaryOp: >=
ID: number1
ID: number2
Compound:
If:
BinaryOp: ==
ID: number1
ID: number2
Compound:
FuncCall:
ID: printf
ExprList:
Constant: string, "Result: %d = %d"
ID: number1
ID: number2
Compound:
FuncCall:
ID: printf
ExprList:
Constant: string, "Result: %d > %d"
ID: number1
ID: number2
Compound:
FuncCall:
ID: printf
ExprList:
Constant: string, "Result: %d < %d"
ID: number1
ID: number2
Return:
Constant: int, 0
最佳答案
这看起来像一个正确的 AST。顶部的所有 Typedef
节点都来自 pycparser 的“假” header ,以帮助它正确解析文件,您几乎可以忽略它们。
AST 只是一个递归的节点树;每个节点都是一个 Node目的。您可以迭代它的子节点(其他节点),使用 .coord
属性查看其原始源位置,等等。有几个查看 AST 节点的示例,例如 explore_ast .
要查找特定节点,您可能需要编写访问者。有几个这样做的例子,比如 func_calls .
关于c - pycparser AST 节点指针/位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54717008/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!