![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2005
Location: Austin, TX
Posts: 15
Rep Power: 0
![]() |
Pyparsing is a Python module for creating parsers. Here is a parser for "Hello, World!", or any string of the form "<greeting>, <person>!":
greeting = Word(alphas) + "," + Word(alphas) + "!"
print greeting.parseString("Hello, World!")
print greeting.parseString("Yo, Adrian!")prints: ['Hello', ',', 'World', '!'] ['Yo', ',', 'Adrian', '!'] Pyparsing can be used to parse text, scan text, and transform text. The Wiki (and the source and docs distributions) contain a number of examples, and epydoc class documentation. UML class diagrams are also included. I gave two presentations on pyparsing at PyCon'06, and there are links to online versions at the Wiki documentation page. Google for "pyparsing" to find more online material. Here is a short list of some of the examples provided: - "Hello, World!" (English, Korean, Greek, and Spanish) - chemical formulas - configuration file parser - web page URL extractor - 5-function arithmetic expression parser - subset of CORBA IDL - chess portable game notation - simple SQL parser - search query parser - EBNF parser/compiler - Python value string parser (lists, dicts, tuples, with nesting) (safe alternative to eval) - HTML tag stripper - S-expression parser - macro substitution preprocessor You can find what other uses pyparsing has been put to at the Wiki Who's Using Pyparsing page. I just posted the latest version update to SourceForge, and you can find out more at the pyparsing Wiki: http://pyparsing.wikispaces.com. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [tutorial] Python for programming beginners | coldDeath | Python | 30 | Dec 14th, 2005 11:35 AM |
| Convert Python script to C++ code | clanotheduck | Python | 17 | Sep 25th, 2005 8:55 AM |
| Advanced Python Tricks | Arevos | Python | 19 | Sep 24th, 2005 7:39 AM |
| Hybrid python shell | Arevos | Existing Project Development | 0 | Sep 22nd, 2005 4:37 PM |
| Python - A Programmers Introduction | coldDeath | Python | 17 | Aug 19th, 2005 12:41 PM |