pyparsing: A Python Library for Creating PEG Parsers
This repository profile is provided by osrepos.com, an open source repository discovery platform.

Summary
pyparsing is a Python library that offers an alternative to traditional lex/yacc or regular expressions for creating simple grammars. It allows developers to construct parsers directly in Python code, leveraging a Parsing Expression Grammar (PEG) approach. This library simplifies handling common parsing challenges like whitespace, quoted strings, and embedded comments, making text processing more intuitive.
Repository Information
Topics
Click on any tag to explore related repositories
Use at your own risk
OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.
Introduction
pyparsing is a powerful Python library designed for creating Parsing Expression Grammars (PEGs) directly within Python code. It provides an intuitive and readable alternative to traditional parser generators like lex/yacc or complex regular expressions. With pyparsing, you define your grammar using a collection of classes and operators, making the parsing logic clear and concise. This approach simplifies the development of parsers for various text formats, from simple greetings to complex configuration files and domain-specific languages.
Installation
To get started with pyparsing, you can easily install it using pip:
pip install pyparsing
Examples
pyparsing's strength lies in its readability and ease of use. Here's a classic "Hello, World!" example demonstrating how to parse a simple greeting:
from pyparsing import Word, alphas
greet = Word(alphas) + "," + Word(alphas) + "!"
hello = "Hello, World!"
print(hello, "->", greet.parse_string(hello))
This program will output:
Hello, World! -> ['Hello', ',', 'World', '!']
The parse_string() method returns a ParseResults object, which can be accessed like a nested list, a dictionary, or an object with named attributes, offering great flexibility in handling parsed data.
Why Use pyparsing?
pyparsing addresses several common pain points in text parsing:
- Flexibility with Whitespace: It automatically handles extra or missing whitespace, allowing for variations like "Hello,World!" or "Hello , World !".
- Quoted Strings and Comments: The library provides built-in support for parsing quoted strings and embedded comments, reducing boilerplate code.
- Readability: Grammars are defined directly in Python, using self-explanatory class names and operator overloads (
+,|,^), which enhances code readability and maintainability. - Rich Examples: The project includes a diverse
examplesdirectory, showcasing parsers for SQL, CORBA IDL, config files, chemical formulas, and algebraic notation, demonstrating its versatility.
Links
- GitHub Repository: https://github.com/pyparsing/pyparsing
- Online Documentation: https://pyparsing-docs.readthedocs.io/en/latest/
- GitHub Wiki: https://github.com/pyparsing/pyparsing/wiki
- Examples Directory: https://github.com/pyparsing/pyparsing/tree/master/examples
Related repositories
Similar repositories that may be relevant next.

Maskit: Local Privacy Gateway for LLMs and AI Tools
September 20, 2026
Maskit is a local privacy desensitization gateway engineered for large language models and AI tools. It automatically masks sensitive data in requests sent to AI services and then seamlessly restores it in streaming responses, ensuring private information remains local. This innovative solution supports various AI assistants like Cursor and Claude Code, along with any tool offering a configurable Base URL.

CyberVerse: Self-Hosted Real-Time Digital Human Agent Platform
September 18, 2026
CyberVerse is an open-source, self-hosted platform for building real-time digital human agents. It leverages WebRTC, persona memory, tools, and RAG to create voice-first AI agents, with optional digital-human video capabilities. This powerful framework allows developers to create highly interactive and lifelike AI companions.

ctx-gate: LLM Context Gateway for Efficient Token Usage
September 16, 2026
ctx-gate is an LLM-agnostic context optimization proxy that reduces token consumption in AI interactions. It intelligently prunes conversation history and tool outputs, ensuring critical facts are retained without altering your workflow. Compatible with Anthropic and OpenAI APIs, ctx-gate helps developers manage LLM costs and maintain prompt fidelity.
Ferret MCP: AI-Powered Knowledge Extraction for Any Codebase
September 14, 2026
Ferret MCP is an MCP server designed to extract comprehensive knowledge from any codebase, combining static analysis with AI-powered deep interpretation. It provides detailed insights into architecture, patterns, dependencies, and API surface, delivering a senior engineer's analysis in seconds. This tool integrates seamlessly with various MCP clients, offering both free static analysis and advanced AI-driven reports.
Source repository
Open the original repository on GitHub.
13 counted GitHub visits