|
Monero
|
Classes | |
| class | CodeNode |
| class | Cursor |
| class | ElseNode |
| class | Env |
| class | ExpNode |
| class | ForNode |
| class | IfNode |
| class | LiteralDollarNode |
| class | Output |
| class | RangeNode |
| class | RawCodeNode |
| class | Token |
| class | VarNode |
Functions | |
| def | Eof () |
| def | StartsWith (lines, pos, string) |
| def | FindFirstInLine (line, token_table) |
| def | FindFirst (lines, token_table, cursor) |
| def | SubString (lines, start, end) |
| def | StripMetaComments (str) |
| def | MakeToken (lines, start, end, token_type) |
| def | ParseToken (lines, pos, regex, token_type) |
| def | Skip (lines, pos, regex) |
| def | SkipUntil (lines, pos, regex, token_type) |
| def | ParseExpTokenInParens (lines, pos) |
| def | RStripNewLineFromToken (token) |
| def | TokenizeLines (lines, pos) |
| def | Tokenize (s) |
| def | PopFront (a_list) |
| def | PushFront (a_list, elem) |
| def | PopToken (a_list, token_type=None) |
| def | PeekToken (a_list) |
| def | ParseExpNode (token) |
| def | ParseElseNode (tokens) |
| def | ParseAtomicCodeNode (tokens) |
| def | ParseCodeNode (tokens) |
| def | ParseToAST (pump_src_text) |
| def | RunAtomicCode (env, node, output) |
| def | RunCode (env, code_node, output) |
| def | IsSingleLineComment (cur_line) |
| def | IsInPreprocessorDirective (prev_lines, cur_line) |
| def | WrapComment (line, output) |
| def | WrapCode (line, line_concat, output) |
| def | WrapPreprocessorDirective (line, output) |
| def | WrapPlainCode (line, output) |
| def | IsMultiLineIWYUPragma (line) |
| def | IsHeaderGuardIncludeOrOneLineIWYUPragma (line) |
| def | WrapLongLine (line, output) |
| def | BeautifyCode (string) |
| def | ConvertFromPumpSource (src_text) |
| def | main (argv) |
Variables | |
| str | __author__ = 'wan@google.com (Zhanyong Wan)' |
| list | TOKEN_TABLE |
| re | ID_REGEX = re.compile(r'[_A-Za-z]\w*') |
| re | EQ_REGEX = re.compile(r'=') |
| re | REST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\$\$)') |
| re | OPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\s*') |
| re | WHITE_SPACE_REGEX = re.compile(r'\s') |
| re | DOT_DOT_REGEX = re.compile(r'\.\.') |
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.
| def pump.BeautifyCode | ( | string | ) |
| def pump.ConvertFromPumpSource | ( | src_text | ) |
Return the text generated from the given Pump source text.
| def pump.Eof | ( | ) |
Returns the special cursor to denote the end-of-file.
| def pump.FindFirst | ( | lines, | |
| token_table, | |||
| cursor | |||
| ) |
Finds the first occurrence of any string in strings in lines.
| def pump.FindFirstInLine | ( | line, | |
| token_table | |||
| ) |
| def pump.IsHeaderGuardIncludeOrOneLineIWYUPragma | ( | line | ) |
| def pump.IsInPreprocessorDirective | ( | prev_lines, | |
| cur_line | |||
| ) |
| def pump.IsMultiLineIWYUPragma | ( | line | ) |
| def pump.IsSingleLineComment | ( | cur_line | ) |
| def pump.main | ( | argv | ) |
| def pump.MakeToken | ( | lines, | |
| start, | |||
| end, | |||
| token_type | |||
| ) |
Creates a new instance of Token.
| def pump.ParseAtomicCodeNode | ( | tokens | ) |
| def pump.ParseCodeNode | ( | tokens | ) |
| def pump.ParseElseNode | ( | tokens | ) |
| def pump.ParseExpNode | ( | token | ) |
| def pump.ParseExpTokenInParens | ( | lines, | |
| pos | |||
| ) |
| def pump.ParseToAST | ( | pump_src_text | ) |
Convert the given Pump source text into an AST.
| def pump.ParseToken | ( | lines, | |
| pos, | |||
| regex, | |||
| token_type | |||
| ) |
| def pump.PeekToken | ( | a_list | ) |
| def pump.PopFront | ( | a_list | ) |
| def pump.PopToken | ( | a_list, | |
token_type = None |
|||
| ) |
| def pump.PushFront | ( | a_list, | |
| elem | |||
| ) |
| def pump.RStripNewLineFromToken | ( | token | ) |
| def pump.RunAtomicCode | ( | env, | |
| node, | |||
| output | |||
| ) |
| def pump.RunCode | ( | env, | |
| code_node, | |||
| output | |||
| ) |
| def pump.Skip | ( | lines, | |
| pos, | |||
| regex | |||
| ) |
| def pump.SkipUntil | ( | lines, | |
| pos, | |||
| regex, | |||
| token_type | |||
| ) |
| def pump.StartsWith | ( | lines, | |
| pos, | |||
| string | |||
| ) |
Returns True iff the given position in lines starts with 'string'.
| def pump.StripMetaComments | ( | str | ) |
Strip meta comments from each line in the given string.
| def pump.SubString | ( | lines, | |
| start, | |||
| end | |||
| ) |
Returns a substring in lines.
| def pump.Tokenize | ( | s | ) |
A generator that yields the tokens in the given string.
| def pump.TokenizeLines | ( | lines, | |
| pos | |||
| ) |
| def pump.WrapCode | ( | line, | |
| line_concat, | |||
| output | |||
| ) |
| def pump.WrapComment | ( | line, | |
| output | |||
| ) |
| def pump.WrapLongLine | ( | line, | |
| output | |||
| ) |
| def pump.WrapPlainCode | ( | line, | |
| output | |||
| ) |
| def pump.WrapPreprocessorDirective | ( | line, | |
| output | |||
| ) |
|
private |
| re pump.DOT_DOT_REGEX = re.compile(r'\.\.') |
| re pump.EQ_REGEX = re.compile(r'=') |
| re pump.ID_REGEX = re.compile(r'[_A-Za-z]\w*') |
| re pump.OPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\s*') |
| re pump.REST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\$\$)') |
| list pump.TOKEN_TABLE |
| re pump.WHITE_SPACE_REGEX = re.compile(r'\s') |