| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
pyparsing.Word Class Reference
Inheritance diagram for pyparsing.Word:
[legend]
Collaboration diagram for pyparsing.Word:
[legend]

## Public Member Functions
def | __init__
def | parseImpl
def | __str__
Public Member Functions inherited from pyparsing.Token
def | __init__
def | setName
Public Member Functions inherited from pyparsing.ParserElement
def | setDefaultWhitespaceChars
def | __init__
def | copy
def | setName
def | setResultsName
def | setBreak
def | setParseAction
def | addParseAction
def | setFailAction
def | preParse
def | parseImpl
def | postParse
def | tryParse
def | resetCache
def | enablePackrat
def | parseString
def | scanString
def | transformString
def | searchString
def | __add__
def | __radd__
def | __sub__
def | __rsub__
def | __mul__
def | __rmul__
def | __or__
def | __ror__
def | __xor__
def | __rxor__
def | __and__
def | __rand__
def | __invert__
def | __call__
def | suppress
def | leaveWhitespace
def | setWhitespaceChars
def | parseWithTabs
def | ignore
def | setDebugActions
def | setDebug
def | __str__
def | __repr__
def | streamline
def | checkRecursion
def | validate
def | parseFile
def | getException
def | __getattr__
def | __eq__
def | __ne__
def | __hash__
def | __req__
def | __rne__

## Public Attributes
| initCharsOrig
| initChars
| bodyCharsOrig
| bodyChars
| maxSpecified
| minLen
| maxLen
| name
| errmsg
| mayIndexError
| asKeyword
| reString
| re
| strRepr
Public Attributes inherited from pyparsing.Token
| errmsg
Public Attributes inherited from pyparsing.ParserElement
| parseAction
| failAction
| strRepr
| resultsName
| saveAsList
| skipWhitespace
| whiteChars
| copyDefaultWhiteChars
| mayReturnEmpty
| keepTabs
| ignoreExprs
| debug
| streamlined
| mayIndexError
| errmsg
| modalResults
| debugActions
| re
| callPreparse
| callDuringTry
| name
| myException

## Additional Inherited Members
Static Public Attributes inherited from pyparsing.ParserElement
string | DEFAULT_WHITE_CHARS " \n\t\r"
tuple | setDefaultWhitespaceChars staticmethod(setDefaultWhitespaceChars)
tuple | resetCache staticmethod(resetCache)
tuple | enablePackrat staticmethod(enablePackrat)

## Detailed Description

    Token for matching words composed of allowed character sets.
       Defined with string containing all allowed initial characters,
       an optional string containing allowed body characters (if omitted,
       defaults to the initial character set), and an optional minimum,
       maximum, and/or exact length.  The default value for min is 1 (a
       minimum value < 1 is not valid); the default values for max and exact
       are 0, meaning no maximum or exact length restriction.

Definition at line 1614 of file pyparsing.py.

## Constructor & Destructor Documentation

def pyparsing.Word.__init__ | ( |  | self,
|  |  | initChars,
|  |  | bodyChars = `None`,
|  |  | min = `1`,
|  |  | max = `0`,
|  |  | exact = `0`,
|  |  | asKeyword = `False`
| ) |  |

Definition at line 1623 of file pyparsing.py.

1623
1624 def __init__( self, initChars, bodyChars=None, min=1, max=0, exact=0, asKeyword=False ):
1625 super(Word,self).__init__()
1626 self.initCharsOrig = initChars
1627 self.initChars = _str2dict(initChars)
1628 if bodyChars :
1629 self.bodyCharsOrig = bodyChars
1630 self.bodyChars = _str2dict(bodyChars)
1631 else:
1632 self.bodyCharsOrig = initChars
1633 self.bodyChars = _str2dict(initChars)
1634
1635 self.maxSpecified = max > 0
1636
1637 if min < 1:
1638 raise ValueError("cannot specify a minimum length < 1; use Optional(Word()) if zero-length word is permitted")
1639
1640 self.minLen = min
1641
1642 if max > 0:
1643 self.maxLen = max
1644 else:
1645 self.maxLen = _MAX_INT
1646
1647 if exact > 0:
1648 self.maxLen = exact
1649 self.minLen = exact
1650
1651 self.name = _ustr(self)
1652 self.errmsg = "Expected " + self.name
1653 #self.myException.msg = self.errmsg
1654 self.mayIndexError = False
1655 self.asKeyword = asKeyword
1656
1657 if ' ' not in self.initCharsOrig+self.bodyCharsOrig and (min==1 and max==0 and exact==0):
1658 if self.bodyCharsOrig == self.initCharsOrig:
1659 self.reString = "[%s]+" % _escapeRegexRangeChars(self.initCharsOrig)
1660 elif len(self.bodyCharsOrig) == 1:
1661 self.reString = "%s[%s]*" % \
1662 (re.escape(self.initCharsOrig),
1663 _escapeRegexRangeChars(self.bodyCharsOrig),)
1664 else:
1665 self.reString = "[%s][%s]*" % \
1666 (_escapeRegexRangeChars(self.initCharsOrig),
1667 _escapeRegexRangeChars(self.bodyCharsOrig),)
1668 if self.asKeyword:
1669 self.reString = r"\b"+self.reString+r"\b"
1670 try:
1671 self.re = re.compile( self.reString )
1672 except:
1673 self.re = None

## Member Function Documentation

def pyparsing.Word.__str__ | ( |  | self | ) |

Definition at line 1719 of file pyparsing.py.

1719
1720 def __str__( self ):
1721 try:
1722 return super(Word,self).__str__()
1723 except:
1724 pass
1725
1726
1727 if self.strRepr is None:
1728
1729 def charsAsStr(s):
1730 if len(s)>4:
1731 return s[:4]+"..."
1732 else:
1733 return s
1734
1735 if ( self.initCharsOrig != self.bodyCharsOrig ):
1736 self.strRepr = "W:(%s,%s)" % ( charsAsStr(self.initCharsOrig), charsAsStr(self.bodyCharsOrig) )
1737 else:
1738 self.strRepr = "W:(%s)" % charsAsStr(self.initCharsOrig)
1739
1740 return self.strRepr
1741

def pyparsing.Word.parseImpl | ( |  | self,
|  |  | instring,
|  |  | loc,
|  |  | doActions = `True`
| ) |  |

Definition at line 1674 of file pyparsing.py.

1674
1675 def parseImpl( self, instring, loc, doActions=True ):
1676 if self.re:
1677 result = self.re.match(instring,loc)
1678 if not result:
1679 exc = self.myException
1680 exc.loc = loc
1681 exc.pstr = instring
1682 raise exc
1683
1684 loc = result.end()
1685 return loc,result.group()
1686
1687 if not(instring[ loc ] in self.initChars):
1688 #~ raise ParseException( instring, loc, self.errmsg )
1689 exc = self.myException
1690 exc.loc = loc
1691 exc.pstr = instring
1692 raise exc
1693 start = loc
1694 loc += 1
1695 instrlen = len(instring)
1696 bodychars = self.bodyChars
1697 maxloc = start + self.maxLen
1698 maxloc = min( maxloc, instrlen )
1699 while loc < maxloc and instring[loc] in bodychars:
1700 loc += 1
1701
1702 throwException = False
1703 if loc - start < self.minLen:
1704 throwException = True
1705 if self.maxSpecified and loc < instrlen and instring[loc] in bodychars:
1706 throwException = True
1707 if self.asKeyword:
1708 if (start>0 and instring[start-1] in bodychars) or (loc<instrlen and instring[loc] in bodychars):
1709 throwException = True
1710
1711 if throwException:
1712 #~ raise ParseException( instring, loc, self.errmsg )
1713 exc = self.myException
1714 exc.loc = loc
1715 exc.pstr = instring
1716 raise exc
1717
1718 return loc, instring[start:loc]

## Member Data Documentation

pyparsing.Word.asKeyword

Definition at line 1654 of file pyparsing.py.

pyparsing.Word.bodyChars

Definition at line 1629 of file pyparsing.py.

pyparsing.Word.bodyCharsOrig

Definition at line 1628 of file pyparsing.py.

pyparsing.Word.errmsg

Definition at line 1651 of file pyparsing.py.

pyparsing.Word.initChars

Definition at line 1626 of file pyparsing.py.

pyparsing.Word.initCharsOrig

Definition at line 1625 of file pyparsing.py.

pyparsing.Word.maxLen

Definition at line 1642 of file pyparsing.py.

pyparsing.Word.maxSpecified

Definition at line 1634 of file pyparsing.py.

pyparsing.Word.mayIndexError

Definition at line 1653 of file pyparsing.py.

pyparsing.Word.minLen

Definition at line 1639 of file pyparsing.py.

pyparsing.Word.name

Definition at line 1650 of file pyparsing.py.

pyparsing.Word.re

Definition at line 1670 of file pyparsing.py.

pyparsing.Word.reString

Definition at line 1658 of file pyparsing.py.

pyparsing.Word.strRepr

Definition at line 1735 of file pyparsing.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/cmake/cmt2cmake/pyparsing.py