Back to index

enigmail  1.4.3
Classes | Functions | Variables
pymake.parser Namespace Reference


class  SyntaxError
class  Data


def enumeratelines


tuple _log = logging.getLogger('pymake.parser')
tuple _skipws = re.compile('\S')
tuple _linere = re.compile(r'\\*\n')

Detailed Description

Module for parsing Makefile syntax.

Makefiles use a line-based parsing system. Continuations and substitutions are handled differently based on the
type of line being parsed:

Lines with makefile syntax condense continuations to a single space, no matter the actual trailing whitespace
of the first line or the leading whitespace of the continuation. In other situations, trailing whitespace is

Lines with command syntax do not condense continuations: the backslash and newline are part of the command.
(GNU Make is buggy in this regard, at least on mac).

Lines with an initial tab are commands if they can be (there is a rule or a command immediately preceding).
Otherwise, they are parsed as makefile syntax.

This file parses into the data structures defined in the parserdata module. Those classes are what actually
do the dirty work of "executing" the parsed data into a data.Makefile.

Four iterator functions are available:
* iterdata
* itermakefilechars
* itercommandchars

The iterators handle line continuations and comments in different ways, but share a common calling

Called with (data, startoffset, tokenlist, finditer)

yield 4-tuples (flatstr, token, tokenoffset, afteroffset)
flatstr is data, guaranteed to have no tokens (may be '')
token, tokenoffset, afteroffset *may be None*. That means there is more text

Function Documentation

def pymake.parser.enumeratelines (   s,
Enumerate lines in a string as Data objects, joining line

Definition at line 79 of file

00080 def enumeratelines(s, filename):
00081     """
00082     Enumerate lines in a string as Data objects, joining line
00083     continuations.
00084     """
00086     off = 0
00087     lineno = 1
00088     curlines = 0
00089     for m in _linere.finditer(s):
00090         curlines += 1
00091         start, end = m.span(0)
00093         if (start - end) % 2 == 0:
00094             # odd number of backslashes is a continuation
00095             continue
00097         yield Data(s, off, end - 1, parserdata.Location(filename, lineno, 0))
00099         lineno += curlines
00100         curlines = 0
00101         off = end
00103     yield Data(s, off, len(s), parserdata.Location(filename, lineno, 0))

Here is the caller graph for this function:

Variable Documentation

tuple pymake.parser._linere = re.compile(r'\\*\n')

Definition at line 78 of file

tuple pymake.parser._log = logging.getLogger('pymake.parser')

Definition at line 39 of file

tuple pymake.parser._skipws = re.compile('\S')

Definition at line 44 of file