Editra  0.7.08
Editra API Documentation
 All Classes Namespaces Functions Variables Properties
Classes | Functions | Variables
codebrowser::gentag::parselib Namespace Reference

Classes

class  TokenNotFound
 Parsing exception. More...
class  ELexer
 A wrapper to add peeking and line counting to pygments lexer. More...
class  EToken

Functions

def GetTokenValue
 Get the first value associated with the given token type in the line will raise TokenNotFound if the value cannot be found.
def HasToken
 Find if the token exists in the line.
def BeginsWithToken
 Returns true it the first non whitespace token in the given line is the given token.
def BeginsWithAnyOf
 Returns true if the line begins with any of the given values.
def GetFirstIdentifier
 Extract the first identifier from the given line.
def GetTokenParenLeft
 Get the first identifier token to the left of the first opening paren found in the given line.
def IsGoodName
 Check if the name is a valid identifier name or not.
def IsToken
 Check if the given item is a token or not.
def SkipWhitespace
 Increment and return the index in the current line past any whitespace.
def FindStringEnd
 Walk through the string until the next non escaped matching ending quotation is found.

Variables

string __author__ = "Cody Precord <cprecord@editra.org>"
 Contains misc common parsing helper functions used by the various parsers in this library.
string __svnid__ = "$Id: parselib.py 70229 2012-01-01 01:27:10Z CJP $"
string __revision__ = "$Revision: 70229 $"

Function Documentation

def codebrowser.gentag.parselib.BeginsWithAnyOf (   line,
  searchToken,
  searchValueList 
)

Returns true if the line begins with any of the given values.

Parameters:
searchValueListlist of unicode
See also:
BeginsWithToken
def codebrowser.gentag.parselib.BeginsWithToken (   line,
  searchToken,
  searchValue 
)

Returns true it the first non whitespace token in the given line is the given token.

Parameters:
linepygments line enumeration
searchTokenpygments.Token.
searchValueunicode
def codebrowser.gentag.parselib.FindStringEnd (   line,
  idx 
)

Walk through the string until the next non escaped matching ending quotation is found.

Returning the current state of the parse. The first character in the given line should be the beginning of the string.

Parameters:
lineline of text
idxcurrent index in parse document
Returns:
(idx, still_string)

Extract the first identifier from the given line.

Identifiers are classified as the first contiguous string of characters that only contains AlphaNumeric or "_" character. In other words [a-zA-Z0-9_]+.

Returns:
identifier name or None
def codebrowser.gentag.parselib.GetTokenParenLeft (   line,
  exchars = '_' 
)

Get the first identifier token to the left of the first opening paren found in the given line.

Example: function myfunct(param1) => myfunct

Parameters:
lineline to search
excharsExtra non-alphanumeric characters that can be in the token
Returns:
string or None
def codebrowser.gentag.parselib.GetTokenValue (   line,
  searchToken 
)

Get the first value associated with the given token type in the line will raise TokenNotFound if the value cannot be found.

Returns:
string
def codebrowser.gentag.parselib.HasToken (   line,
  searchToken,
  searchValue = None 
)

Find if the token exists in the line.

Parameters:
lineline of code
searchTokenToken to look for
Returns:
bool
Note:
use sparingly as this can be slow
def codebrowser.gentag.parselib.IsGoodName (   name,
  exchars = '_' 
)

Check if the name is a valid identifier name or not.

A valid identifier is a string that only has alpha numeric and/or the specified exchars in it. Also meaning it matches the following character class [a-zA-Z_][a-zA-Z0-8_]+

Parameters:
namename to check
excharsextra non alphanumeric characters that are valid
Returns:
bool
def codebrowser.gentag.parselib.IsToken (   line,
  idx,
  name,
  ignorecase = False 
)

Check if the given item is a token or not.

The function will return True if the item at the given index matches the name and is preceded and followed by whitespace. It will return False otherwise.

Parameters:
linestring to check
idxindex in string to look from
namename of token to look for match
ignorecasedo case insensitive search
Returns:
bool
def codebrowser.gentag.parselib.SkipWhitespace (   line,
  idx 
)

Increment and return the index in the current line past any whitespace.

Parameters:
linestring
idxindex to check from in line
Returns:
int

Variable Documentation

string __author__ = "Cody Precord <cprecord@editra.org>"

Contains misc common parsing helper functions used by the various parsers in this library.

Common helper functions for tag generators.

string __revision__ = "$Revision: 70229 $"
string __svnid__ = "$Id: parselib.py 70229 2012-01-01 01:27:10Z CJP $"
 All Classes Namespaces Functions Variables Properties