chartypes.py :  » Parser » SimpleParse » SimpleParse-2.1.1a2 » common » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Parser » SimpleParse 
SimpleParse » SimpleParse 2.1.1a2 » common » chartypes.py
"""Common locale-specific character types

Following productions are all based on string module,
with the default locale specified.  The first production
is a single character of the class and the second a
repeating character version:

  digit, digits
  uppercasechar, uppercase
  lowercasechar, lowercase
  letter, letters
  whitespacechar, whitespace
  punctuationchar, punctuation
  octdigit, octdigits
  hexdigit, hexdigits
  printablechar, printable

For Python versions with the constants in the string module:
  ascii_letter, ascii_letters
  ascii_lowercasechar, ascii_lowercase
  ascii_uppercasechar, ascii_uppercase


Following are locale-specific values, both are
single-character values:

  locale_decimal_point -- locale-specific decimal seperator
  locale_thousands_seperator -- locale-specific "thousands" seperator
  
Others:

  EOF -- Matches iff parsing has reached the end of the buffer

There are no interpreters provided (the types are considered
too common to provide meaningful interpreters).
"""
from simpleparse import objectgenerator,common
import string, locale
locale.setlocale(locale.LC_ALL, "" )

c = {}

# string-module items...

for source,single,repeat in [
  ("digits","digit","digits"),
  ("uppercase", "uppercasechar", "uppercase"),
  ("lowercase", "lowercasechar", "lowercase"),
  ("letters", "letter", "letters" ),
  ("ascii_lowercase", "ascii_lowercasechar", "ascii_lowercase"),
  ("ascii_uppercase", "ascii_uppercasechar", "ascii_uppercase"),
  ("ascii_letters", "ascii_letter", "ascii_letters" ),
  ("whitespace", "whitespacechar", "whitespace"),
  ("punctuation", "punctuationchar", "punctuation"),
  ("octdigits", "octdigit", "octdigits"),
  ("hexdigits", "hexdigit", "hexdigits"),
  ("printable", "printablechar", "printable"),
]:
  try:
    value = getattr( string, source )
    c[ single ] = objectgenerator.Range( value = value )
    c[ repeat ] = objectgenerator.Range( value = value, repeating =1 )
  except AttributeError:
    pass

# locale-module items
_lc = locale.localeconv()
c[ "locale_decimal_point" ] = objectgenerator.Literal( value = _lc["decimal_point"] )
c[ "locale_thousands_seperator" ] = objectgenerator.Literal( value = _lc["thousands_sep"] )

del _lc

# common, but not really well defined sets
# this is the set of characters which are interpreted
# specially by Python's string-escaping when they
# follow a \\ char.

from simpleparse.stt import TextTools
c[ "EOF" ] = objectgenerator.Prebuilt( value = (
  (None, TextTools.EOF, TextTools.Here),
) )

common.share( c )
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.