parser.py¶
from pymwp import Parser
Parser implementation is not a native part of pymwp.
Parsing is implemented with pycparser.
The Parser
module is simply a convenient wrapper.
Enhancements and issues with C-file parsing are out of scope of pymwp.
ParserInterface
¶
Bases: Nodes
Interface for C code parser.
parse
abstractmethod
staticmethod
¶
parse(full_file_name: str, **kwargs) -> dict
Extract text from the currently loaded file.
PyCParser
¶
Bases: ParserInterface
Implementation of the parser interface using pycparser.
add_attr_x
staticmethod
¶
add_attr_x(text: str) -> str
Conditionally add #define __attribute__(x)
to C file
for pycparser.
See: https://github.com/eliben/pycparser/wiki/FAQ#what-do-i-do -about-__attribute__/
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
C program file content as a string |
required |
Returns:
Type | Description |
---|---|
str
|
contents of C file, with |