Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
PartialPreprocessor Class Reference
Inheritance diagram for PartialPreprocessor:

Public Member Functions

 __init__ (self, [(str, Optional[str])] defs, [(str, str)] replaces, [str] undefs)
 
 preprocess (self, filename)
 
 __init__ (self, [(str, Optional[str])] defs, [(str, str)] replaces, [str] undefs)
 
 preprocess (self, filename)
 
 __init__ (self, [(str, Optional[str])] defs, [(str, str)] replaces, [str] undefs)
 
 preprocess (self, filename)
 

Data Fields

bool _inlines = True
 

Protected Member Functions

 _log (self, *args, **kwargs)
 
 _strip_comments (self, line)
 
 _fixup_indentation (self, macro, [str] replace)
 
 _handle_if_block (self, macro, idx, is_true, prepend)
 
 _preprocess_once (self)
 
 _log (self, *args, **kwargs)
 
 _strip_comments (self, line)
 
 _fixup_indentation (self, macro, [str] replace)
 
 _handle_if_block (self, macro, idx, is_true, prepend)
 
 _preprocess_once (self)
 
 _log (self, *args, **kwargs)
 
 _strip_comments (self, line)
 
 _fixup_indentation (self, macro, [str] replace)
 
 _handle_if_block (self, macro, idx, is_true, prepend)
 
 _preprocess_once (self)
 

Protected Attributes

dict _defs = {macro:value for macro, value in defs}
 
dict _replaces = {macro:value for macro, value in replaces}
 
 _undefs = set(undefs)
 
 _define = re.compile(r"\s*#\s*define")
 
 _if = re.compile(r"\s*#\s*if")
 
 _elif = re.compile(r"\s*#\s*(?P<elif>el)if")
 
 _else = re.compile(r"\s*#\s*(?P<else>else)")
 
 _endif = re.compile(r"\s*#\s*endif")
 
 _ifdef = re.compile(fr"\s*#\s*if(?P<not>n)?def {MACRO_GROUP}\s*")
 
 _if_defined
 
 _if_defined_value
 
 _if_true
 
 _c_comment = re.compile(r"/\*.*?\*/")
 
 _cpp_comment = re.compile(r"//")
 
 _inlines = outlines
 

Detailed Description

Looks for simple ifdefs and ifndefs and replaces them.
Handles && and ||.
Has fancy logic to handle translating elifs to ifs.
Only looks for macros in the first part of the expression with no
parens.
Does not handle multi-line macros (only looks in first line).

Constructor & Destructor Documentation

◆ __init__() [1/3]

__init__ ( self,
[(str, Optional[str])] defs,
[(str, str)] replaces,
[str] undefs )

◆ __init__() [2/3]

__init__ ( self,
[(str, Optional[str])] defs,
[(str, str)] replaces,
[str] undefs )

◆ __init__() [3/3]

__init__ ( self,
[(str, Optional[str])] defs,
[(str, str)] replaces,
[str] undefs )

Member Function Documentation

◆ _fixup_indentation() [1/3]

_fixup_indentation ( self,
macro,
[str] replace )
protected

◆ _fixup_indentation() [2/3]

_fixup_indentation ( self,
macro,
[str] replace )
protected

◆ _fixup_indentation() [3/3]

_fixup_indentation ( self,
macro,
[str] replace )
protected

◆ _handle_if_block() [1/3]

_handle_if_block ( self,
macro,
idx,
is_true,
prepend )
protected
Remove the #if or #elif block starting on this line.

◆ _handle_if_block() [2/3]

_handle_if_block ( self,
macro,
idx,
is_true,
prepend )
protected
Remove the #if or #elif block starting on this line.

◆ _handle_if_block() [3/3]

_handle_if_block ( self,
macro,
idx,
is_true,
prepend )
protected
Remove the #if or #elif block starting on this line.

◆ _log() [1/3]

_log ( self,
* args,
** kwargs )
protected

◆ _log() [2/3]

_log ( self,
* args,
** kwargs )
protected

◆ _log() [3/3]

_log ( self,
* args,
** kwargs )
protected

◆ _preprocess_once() [1/3]

_preprocess_once ( self)
protected

◆ _preprocess_once() [2/3]

_preprocess_once ( self)
protected

◆ _preprocess_once() [3/3]

_preprocess_once ( self)
protected

◆ _strip_comments() [1/3]

_strip_comments ( self,
line )
protected

◆ _strip_comments() [2/3]

_strip_comments ( self,
line )
protected

◆ _strip_comments() [3/3]

_strip_comments ( self,
line )
protected

◆ preprocess() [1/3]

preprocess ( self,
filename )

◆ preprocess() [2/3]

preprocess ( self,
filename )

◆ preprocess() [3/3]

preprocess ( self,
filename )

Field Documentation

◆ _c_comment

_c_comment = re.compile(r"/\*.*?\*/")
protected

◆ _cpp_comment

_cpp_comment = re.compile(r"//")
protected

◆ _define

_define = re.compile(r"\s*#\s*define")
protected

◆ _defs

dict _defs = {macro:value for macro, value in defs}
protected

◆ _elif

_elif = re.compile(r"\s*#\s*(?P<elif>el)if")
protected

◆ _else

_else = re.compile(r"\s*#\s*(?P<else>else)")
protected

◆ _endif

_endif = re.compile(r"\s*#\s*endif")
protected

◆ _if

_if = re.compile(r"\s*#\s*if")
protected

◆ _if_defined

_if_defined
protected
Initial value:
= re.compile(
fr"\s*#\s*{ELIF_GROUP}if\s+(?P<not>!)?\s*defined\s*\‍(\s*{MACRO_GROUP}\s*\‍)\s*{OP_GROUP}"
)

◆ _if_defined_value

_if_defined_value
protected
Initial value:
= re.compile(
fr"\s*#\s*{ELIF_GROUP}if\s+defined\s*\‍(\s*{MACRO_GROUP}\s*\‍)\s*"
fr"(?P<op>&&)\s*"
fr"(?P<openp>\‍()?\s*"
fr"(?P<macro2>[a-zA-Z_][a-zA-Z_0-9]*)\s*"
fr"(?P<cmp>[=><!]+)\s*"
fr"(?P<value>[0-9]*)\s*"
fr"(?P<closep>\‍))?\s*"
)

◆ _if_true

_if_true
protected
Initial value:
= re.compile(
fr"\s*#\s*{ELIF_GROUP}if\s+{MACRO_GROUP}\s*{OP_GROUP}"
)

◆ _ifdef

_ifdef = re.compile(fr"\s*#\s*if(?P<not>n)?def {MACRO_GROUP}\s*")
protected

◆ _inlines [1/2]

bool _inlines = outlines
protected

◆ _inlines [2/2]

bool _inlines = True

◆ _replaces

dict _replaces = {macro:value for macro, value in replaces}
protected

◆ _undefs

_undefs = set(undefs)
protected

The documentation for this class was generated from the following files: