Monero
Loading...
Searching...
No Matches
pump Namespace Reference

Classes

class  Cursor
class  Token
class  CodeNode
class  VarNode
class  RangeNode
class  ForNode
class  ElseNode
class  IfNode
class  RawCodeNode
class  LiteralDollarNode
class  ExpNode
class  Env
class  Output

Functions

 Eof ()
 StartsWith (lines, pos, string)
 FindFirstInLine (line, token_table)
 FindFirst (lines, token_table, cursor)
 SubString (lines, start, end)
 StripMetaComments (str)
 MakeToken (lines, start, end, token_type)
 ParseToken (lines, pos, regex, token_type)
 Skip (lines, pos, regex)
 SkipUntil (lines, pos, regex, token_type)
 ParseExpTokenInParens (lines, pos)
 RStripNewLineFromToken (token)
 TokenizeLines (lines, pos)
 Tokenize (s)
 PopFront (a_list)
 PushFront (a_list, elem)
 PopToken (a_list, token_type=None)
 PeekToken (a_list)
 ParseExpNode (token)
 ParseElseNode (tokens)
 ParseAtomicCodeNode (tokens)
 ParseCodeNode (tokens)
 ParseToAST (pump_src_text)
 RunAtomicCode (env, node, output)
 RunCode (env, code_node, output)
 IsSingleLineComment (cur_line)
 IsInPreprocessorDirective (prev_lines, cur_line)
 WrapComment (line, output)
 WrapCode (line, line_concat, output)
 WrapPreprocessorDirective (line, output)
 WrapPlainCode (line, output)
 IsMultiLineIWYUPragma (line)
 IsHeaderGuardIncludeOrOneLineIWYUPragma (line)
 WrapLongLine (line, output)
 BeautifyCode (string)
 ConvertFromPumpSource (src_text)
 main (argv)

Variables

str __author__ = 'wan@google.com (Zhanyong Wan)'
list TOKEN_TABLE
 ID_REGEX = re.compile(r'[_A-Za-z]\w*')
 EQ_REGEX = re.compile(r'=')
 REST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\$\$)')
 OPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\s*')
 WHITE_SPACE_REGEX = re.compile(r'\s')
 DOT_DOT_REGEX = re.compile(r'\.\.')

Detailed Description

pump v0.2.0 - Pretty Useful for Meta Programming.

A tool for preprocessor meta programming.  Useful for generating
repetitive boilerplate code.  Especially useful for writing C++
classes, functions, macros, and templates that need to work with
various number of arguments.

USAGE:
       pump.py SOURCE_FILE

EXAMPLES:
       pump.py foo.cc.pump
         Converts foo.cc.pump to foo.cc.

GRAMMAR:
       CODE ::= ATOMIC_CODE*
       ATOMIC_CODE ::= $var ID = EXPRESSION
           | $var ID = [[ CODE ]]
           | $range ID EXPRESSION..EXPRESSION
           | $for ID SEPARATOR [[ CODE ]]
           | $($)
           | $ID
           | $(EXPRESSION)
           | $if EXPRESSION [[ CODE ]] ELSE_BRANCH
           | [[ CODE ]]
           | RAW_CODE
       SEPARATOR ::= RAW_CODE | EMPTY
       ELSE_BRANCH ::= $else [[ CODE ]]
           | $elif EXPRESSION [[ CODE ]] ELSE_BRANCH
           | EMPTY
       EXPRESSION has Python syntax.

Function Documentation

◆ BeautifyCode()

pump.BeautifyCode ( string)

◆ ConvertFromPumpSource()

pump.ConvertFromPumpSource ( src_text)
Return the text generated from the given Pump source text.

◆ Eof()

pump.Eof ( )
Returns the special cursor to denote the end-of-file.

◆ FindFirst()

pump.FindFirst ( lines,
token_table,
cursor )
Finds the first occurrence of any string in strings in lines.

◆ FindFirstInLine()

pump.FindFirstInLine ( line,
token_table )

◆ IsHeaderGuardIncludeOrOneLineIWYUPragma()

pump.IsHeaderGuardIncludeOrOneLineIWYUPragma ( line)

◆ IsInPreprocessorDirective()

pump.IsInPreprocessorDirective ( prev_lines,
cur_line )

◆ IsMultiLineIWYUPragma()

pump.IsMultiLineIWYUPragma ( line)

◆ IsSingleLineComment()

pump.IsSingleLineComment ( cur_line)

◆ main()

pump.main ( argv)

◆ MakeToken()

pump.MakeToken ( lines,
start,
end,
token_type )
Creates a new instance of Token.

◆ ParseAtomicCodeNode()

pump.ParseAtomicCodeNode ( tokens)

◆ ParseCodeNode()

pump.ParseCodeNode ( tokens)

◆ ParseElseNode()

pump.ParseElseNode ( tokens)

◆ ParseExpNode()

pump.ParseExpNode ( token)

◆ ParseExpTokenInParens()

pump.ParseExpTokenInParens ( lines,
pos )

◆ ParseToAST()

pump.ParseToAST ( pump_src_text)
Convert the given Pump source text into an AST.

◆ ParseToken()

pump.ParseToken ( lines,
pos,
regex,
token_type )

◆ PeekToken()

pump.PeekToken ( a_list)

◆ PopFront()

pump.PopFront ( a_list)

◆ PopToken()

pump.PopToken ( a_list,
token_type = None )

◆ PushFront()

pump.PushFront ( a_list,
elem )

◆ RStripNewLineFromToken()

pump.RStripNewLineFromToken ( token)

◆ RunAtomicCode()

pump.RunAtomicCode ( env,
node,
output )

◆ RunCode()

pump.RunCode ( env,
code_node,
output )

◆ Skip()

pump.Skip ( lines,
pos,
regex )

◆ SkipUntil()

pump.SkipUntil ( lines,
pos,
regex,
token_type )

◆ StartsWith()

pump.StartsWith ( lines,
pos,
string )
Returns True iff the given position in lines starts with 'string'.

◆ StripMetaComments()

pump.StripMetaComments ( str)
Strip meta comments from each line in the given string.

◆ SubString()

pump.SubString ( lines,
start,
end )
Returns a substring in lines.

◆ Tokenize()

pump.Tokenize ( s)
A generator that yields the tokens in the given string.

◆ TokenizeLines()

pump.TokenizeLines ( lines,
pos )

◆ WrapCode()

pump.WrapCode ( line,
line_concat,
output )

◆ WrapComment()

pump.WrapComment ( line,
output )

◆ WrapLongLine()

pump.WrapLongLine ( line,
output )

◆ WrapPlainCode()

pump.WrapPlainCode ( line,
output )

◆ WrapPreprocessorDirective()

pump.WrapPreprocessorDirective ( line,
output )

Variable Documentation

◆ __author__

str pump.__author__ = 'wan@google.com (Zhanyong Wan)'
private

◆ DOT_DOT_REGEX

pump.DOT_DOT_REGEX = re.compile(r'\.\.')

◆ EQ_REGEX

pump.EQ_REGEX = re.compile(r'=')

◆ ID_REGEX

pump.ID_REGEX = re.compile(r'[_A-Za-z]\w*')

◆ OPTIONAL_WHITE_SPACES_REGEX

pump.OPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\s*')

◆ REST_OF_LINE_REGEX

pump.REST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\$\$)')

◆ TOKEN_TABLE

list pump.TOKEN_TABLE
Initial value:
1= [
2 (re.compile(r'\$var\s+'), '$var'),
3 (re.compile(r'\$elif\s+'), '$elif'),
4 (re.compile(r'\$else\s+'), '$else'),
5 (re.compile(r'\$for\s+'), '$for'),
6 (re.compile(r'\$if\s+'), '$if'),
7 (re.compile(r'\$range\s+'), '$range'),
8 (re.compile(r'\$[_A-Za-z]\w*'), '$id'),
9 (re.compile(r'\$\‍(\$\‍)'), '$($)'),
10 (re.compile(r'\$'), '$'),
11 (re.compile(r'\‍[\‍[\n?'), '[['),
12 (re.compile(r'\‍]\‍]\n?'), ']]'),
13 ]

◆ WHITE_SPACE_REGEX

pump.WHITE_SPACE_REGEX = re.compile(r'\s')