Package Cheetah :: Module Parser :: Class _LowLevelParser
[show private | hide private]
[frames | no frames]

Class _LowLevelParser

SourceReader --+
               |
              _LowLevelParser

Known Subclasses:
_HighLevelParser

This class implements the methods to match or extract ('get*') the basic elements of Cheetah's grammar. It does NOT handle any code generation or state management.
Method Summary
  _initializeSettings(self)
  _makeCheetahVarREs(self)
Setup the regexs for Cheetah $var parsing.
  _makeCommentREs(self)
Construct the regex bits that are used in comment parsing.
  _makeDirectiveREs(self)
Construct the regexs that are used in directive parsing.
  _makePspREs(self)
Setup the regexs for PSP parsing.
  configureParser(self)
Is called by the Compiler instance after the parser has had a settingsManager assigned with self.setSettingsManager()
  getAssignmentOperator(self)
  getCacheToken(self)
  getCallArgString(self, enclosures, useNameMapper)
Get a method/function call argument string.
  getCheetahVar(self, plain, skipStartToken)
This is called when parsing inside expressions.
  getCheetahVarBody(self, plain)
  getCheetahVarNameChunks(self)
[ (namemapperPart,autoCall,restOfName), ]
  getCheetahVarStartToken(self)
just the start token, not the enclosure or cache token
  getCommentStartToken(self)
  getDefArgList(self, exitPos, useNameMapper)
Get an argument list.
  getDirectiveEndToken(self)
  getDirectiveStartToken(self)
  getDottedName(self)
  getEOLSlurpToken(self)
  getExpression(self, enclosed, enclosures, pyTokensToBreakAt, useNameMapper)
Returns the output of self.getExpressionParts() as a concatenated string rather than as a list.
  getExpressionParts(self, enclosed, enclosures, pyTokensToBreakAt, useNameMapper)
Get a Cheetah expression that includes $CheetahVars and break at directive end tokens, the end of an enclosure, or at a specified pyToken.
  getIdentifier(self)
  getMultiLineCommentEndToken(self)
  getMultiLineCommentStartToken(self)
  getOperator(self)
  getPlaceholder(self, allowCacheTokens, plain, returnEverything)
  getPSPEndToken(self)
  getPSPStartToken(self)
  getPyToken(self)
  getSilentPlaceholderToken(self)
  getTargetVarsList(self)
  isLineClearToStartToken(self, pos)
  matchAssignmentOperator(self)
  matchCheetahVarStart(self)
includes the enclosure and cache token
  matchCheetahVarStartToken(self)
includes the enclosure and cache token
  matchColonForSingleLineShortFormDirective(self)
  matchCommentStartToken(self)
  matchDirective(self)
Returns False or the name of the directive matched.
  matchDirectiveEndToken(self)
  matchDirectiveName(self, directiveNameChars)
  matchDirectiveStartToken(self)
  matchEOLSlurpToken(self)
  matchExpressionPlaceholderStart(self)
includes the enclosure and cache token
  matchIdentifier(self)
  matchMultiLineCommentEndToken(self)
  matchMultiLineCommentStartToken(self)
  matchOperator(self)
  matchPSPEndToken(self)
  matchPSPStartToken(self)
  matchPyToken(self)
  matchTopLevelToken(self)
self.matchCommentStartToken self.matchMultiLineCommentStartToken self.matchVariablePlaceholderStart self.matchExpressionPlaceholderStart self.matchDirective self.matchPSPStartToken self.matchEOLSlurpToken
  matchVariablePlaceholderStart(self)
includes the enclosure and cache token
  setSetting(self, key, val)
  setSettingsManager(self, settingsManager)
  setting(self, key, default)
  settings(self)
  transformToken(self, token, beforeTokenPos)
Takes a token from the expression being parsed and performs and special transformations required by Cheetah.
  updateSettings(self, settings)
    Inherited from SourceReader
  __init__(self, src, filename, breakPoint, encoding)
  __getitem__(self, i)
  __getslice__(self, i, j)
  __len__(self)
  advance(self, offset)
  atEnd(self)
  atStart(self)
  breakPoint(self)
  checkPos(self, pos)
  filename(self)
  find(self, it, pos)
  findBOL(self, pos)
  findEOL(self, pos, gobble)
  getc(self)
  getLine(self, pos)
  getNonWhiteSpace(self, WSchars)
  getRowCol(self, pos)
  getRowColLine(self, pos)
  getWhiteSpace(self, max, WSchars)
  gotoBookmark(self, name)
  hasBookmark(self, name)
  isLineClearToPos(self, pos)
  lineNum(self, pos)
  matches(self, strOrRE)
  matchNonWhiteSpace(self, WSchars)
  matchWhiteSpace(self, WSchars)
  peek(self, offset)
  pos(self)
  read(self, offset)
  readTo(self, to, start)
  readToEOL(self, start, gobble)
  rev(self, offset)
  rfind(self, it, pos)
  setBookmark(self, name)
  setBreakPoint(self, pos)
  setPos(self, pos)
  splitlines(self)
  src(self)
  startswith(self, it, pos)
  ungetc(self, c)
  validPos(self, pos)

Class Variable Summary
NoneType _settingsManager = None                                                                  

Method Details

_makeCheetahVarREs(self)

Setup the regexs for Cheetah $var parsing.

_makeCommentREs(self)

Construct the regex bits that are used in comment parsing.

_makeDirectiveREs(self)

Construct the regexs that are used in directive parsing.

_makePspREs(self)

Setup the regexs for PSP parsing.

configureParser(self)

Is called by the Compiler instance after the parser has had a settingsManager assigned with self.setSettingsManager()

getCallArgString(self, enclosures=[], useNameMapper=<class Cheetah.Parser.Unspecified at 0xb6a62c8c>)

Get a method/function call argument string.

This method understands *arg, and **kw

getCheetahVar(self, plain=False, skipStartToken=False)

This is called when parsing inside expressions. Cache tokens are only valid in placeholders so this method discards any cache tokens found.

getCheetahVarNameChunks(self)

nameChunks = list of Cheetah $var subcomponents represented as tuples
[ (namemapperPart,autoCall,restOfName), ]
where:
namemapperPart = the dottedName base autocall = where NameMapper should use autocalling on namemapperPart restOfName = any arglist, index, or slice

If restOfName contains a call arglist (e.g. '(1234)') then autocall is False, otherwise it defaults to True.

EXAMPLE

if the raw CheetahVar is
$a.b.c[1].d().x.y.z
nameChunks is the list
[ ('a.b.c',True,'[1]'),
('d',False,'()'), ('x.y.z',True,''),

]

getCheetahVarStartToken(self)

just the start token, not the enclosure or cache token

getDefArgList(self, exitPos=None, useNameMapper=False)

Get an argument list. Can be used for method/function definition
argument lists or for #directive argument lists. Returns a list of
tuples in the form (argName, defVal=None) with one tuple for each arg
name.

These defVals are always strings, so (argName, defVal=None) is safe even
with a case like (arg1, arg2=None, arg3=1234*2), which would be returned as
[('arg1', None),
 ('arg2', 'None'),
 ('arg3', '1234*2'),         
]

This method understands *arg, and **kw

getExpression(self, enclosed=False, enclosures=None, pyTokensToBreakAt=None, useNameMapper=<class Cheetah.Parser.Unspecified at 0xb6a62c8c>)

Returns the output of self.getExpressionParts() as a concatenated string rather than as a list.

getExpressionParts(self, enclosed=False, enclosures=None, pyTokensToBreakAt=None, useNameMapper=<class Cheetah.Parser.Unspecified at 0xb6a62c8c>)

Get a Cheetah expression that includes $CheetahVars and break at directive end tokens, the end of an enclosure, or at a specified pyToken.

matchCheetahVarStart(self)

includes the enclosure and cache token

matchCheetahVarStartToken(self)

includes the enclosure and cache token

matchDirective(self)

Returns False or the name of the directive matched.

matchExpressionPlaceholderStart(self)

includes the enclosure and cache token

matchTopLevelToken(self)

Returns the first match found from the following methods:
self.matchCommentStartToken self.matchMultiLineCommentStartToken self.matchVariablePlaceholderStart self.matchExpressionPlaceholderStart self.matchDirective self.matchPSPStartToken self.matchEOLSlurpToken

Returns None if no match.

matchVariablePlaceholderStart(self)

includes the enclosure and cache token

transformToken(self, token, beforeTokenPos)

Takes a token from the expression being parsed and performs and special transformations required by Cheetah.

At the moment only Cheetah's c'$placeholder strings' are transformed.


Class Variable Details

_settingsManager

Type:
NoneType
Value:
None                                                                  

Generated by Epydoc 2.1 on Sat Mar 4 13:36:23 2006 http://epydoc.sf.net