Package wafadmin :: Package Tools :: Module preproc
[hide private]
[frames] | no frames]

Module preproc

source code

Classes [hide private]
  PreprocError
  c_parser
Functions [hide private]
 
repl(m) source code
 
filter_comments(filename) source code
 
reduce_nums(val_1, val_2, val_op) source code
 
get_expr(lst, defs, ban) source code
 
process_tokens(lst, defs, ban) source code
 
eval_macro(lst, adefs) source code
 
extract_macro(txt) source code
 
extract_include(txt, defs) source code
 
parse_char(txt) source code
 
tokenize(s) source code
Variables [hide private]
  go_absolute = 0
set to 1 to track headers on files in /usr/include - else absolute paths are ignored
  standard_includes = []
  use_trigraphs = 0
apply the trigraph rules first
  strict_quotes = 0
Keep <> for system includes (do not search for those includes)
  g_optrans = {'not': '!', 'and': '&&', 'bitand': '&', 'and_eq':...
these ops are for c++, to reset, set an empty dict
  re_lines = re.compile('^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|els...
  re_mac = re.compile("^[a-zA-Z_]\w*")
  re_fun = re.compile('^[a-zA-Z_][a-zA-Z0-9_]*[(]')
  re_pragma_once = re.compile('^\s*once\s*', re.IGNORECASE)
  re_nl = re.compile('\\\\\r*\n', re.MULTILINE)
  re_cpp = re.compile(r"""(/\*[^*]*\*+([^/*][^*]*\*+)*/)|//[^\n]...
  trig_def = [('??'+ a, b) for a, b in zip("=-/!'()<>", r'#~\|^[...
  chr_esc = {'0': 0, 'a': 7, 'b': 8, 't': 9, 'n': 10, 'f': 11, '...
  NUM = 'i'
  OP = 'O'
  IDENT = 'T'
  STR = 's'
  CHAR = 'c'
  tok_types = [NUM, STR, IDENT, OP]
  exp_types = [r"""0[xX](?P<hex>[a-fA-F0-9]+)(?P<qual1>[uUlL]*)|...
  re_clexer = re.compile('|'.join(["(?P<%s>%s)" %(name, part) fo...
  accepted = 'a'
  ignored = 'i'
  undefined = 'u'
  skipped = 's'
  prec = {}
  ops = ['* / %', '+ -', '<< >>', '< <= >= >', '== !=', '& | ^',...
  re_include = re.compile('^\s*(<(?P<a>.*)>|"(?P<b>.*)")')
Variables Details [hide private]

g_optrans

these ops are for c++, to reset, set an empty dict

Value:
{'not': '!', 'and': '&&', 'bitand': '&', 'and_eq': '&=', 'or': '||', '\
bitor': '|', 'or_eq': '|=', 'xor': '^', 'xor_eq': '^=', 'compl': '~',}

re_lines

Value:
re.compile('^[ \t]*(#|%:)[ \t]*(ifdef|ifndef|if|else|elif|endif|includ\
e|import|define|undef|pragma)[ \t]*(.*)\r*$', re.IGNORECASE | re.MULTI\
LINE)

re_cpp

Value:
re.compile(r"""(/\*[^*]*\*+([^/*][^*]*\*+)*/)|//[^\n]*|("(\\.|[^"\\])*\
"|'(\\.|[^'\\])*'|.[^/"'\\]*)""", re.MULTILINE)

trig_def

Value:
[('??'+ a, b) for a, b in zip("=-/!'()<>", r'#~\|^[]{}')]

chr_esc

Value:
{'0': 0, 'a': 7, 'b': 8, 't': 9, 'n': 10, 'f': 11, 'v': 12, 'r': 13, '\
\\': 92, "'": 39}

exp_types

Value:
[r"""0[xX](?P<hex>[a-fA-F0-9]+)(?P<qual1>[uUlL]*)|L*?'(?P<char>(\\.|[^\
\\'])+)'|(?P<n1>\d+)[Ee](?P<exp0>[+-]*?\d+)(?P<float0>[fFlL]*)|(?P<n2>\
\d*\.\d+)([Ee](?P<exp1>[+-]*?\d+))?(?P<float1>[fFlL]*)|(?P<n4>\d+\.\d*\
)([Ee](?P<exp2>[+-]*?\d+))?(?P<float2>[fFlL]*)|(?P<oct>0*)(?P<n0>\d+)(\
?P<qual2>[uUlL]*)""", r'L?"([^"\\]|\\.)*"', r'[a-zA-Z_]\w*', r'%:%:|<<\
=|>>=|\.\.\.|<<|<%|<:|<=|>>|>=|\+\+|\+=|--|->|-=|\*=|/=|%:|%=|%>|==|&&\
|&=|\|\||\|=|\^=|:>|!=|##|[\(\)\{\}\[\]<>\?\|\^\*\+&=:!#;,%/\-\?\~\.]'\
,]

re_clexer

Value:
re.compile('|'.join(["(?P<%s>%s)" %(name, part) for name, part in zip(\
tok_types, exp_types)]), re.M)

ops

Value:
['* / %', '+ -', '<< >>', '< <= >= >', '== !=', '& | ^', '&& ||', ',']