{"id":24372,"library":"pypeg2","title":"PyPEG2","description":"An intrinsic PEG Parser-Interpreter for Python, providing a simple way to define grammars using Python classes. Current version 2.15.2; no regular release cadence.","status":"active","version":"2.15.2","language":"python","source_language":"en","source_url":"https://github.com/byt3bl33d3r/pypeg2","tags":["peg","parser","interpreter","grammar"],"install":[{"cmd":"pip install pypeg2","lang":"bash","label":"latest from PyPI"}],"dependencies":[],"imports":[{"note":"correct import path","symbol":"Parser","correct":"from pypeg2 import Parser"},{"note":"correct import path","symbol":"Symbol","correct":"from pypeg2 import Symbol"},{"note":"correct import path","symbol":"Keyword","correct":"from pypeg2 import Keyword"},{"note":"correct import path","symbol":"Namespace","correct":"from pypeg2 import Namespace"},{"note":"correct import path","symbol":"attr","correct":"from pypeg2 import attr"},{"note":"correct import path","symbol":"parse","correct":"from pypeg2 import parse"}],"quickstart":{"code":"from pypeg2 import Symbol, Keyword, attr, parse\n\nclass Name(Symbol):\n    grammar = attr('first', str), attr('last', str)\n\nclass Greeting(Keyword):\n    grammar = 'hello'\n\nclass Sentence:\n    grammar = Greeting, Name\n\nresult = parse('hello John Doe', Sentence)\nprint(result.greeting, result.name.first, result.name.last)","lang":"python","description":"Define a simple grammar with classes and parse a string."},"warnings":[{"fix":"Use the parsed object's attributes directly; do not rely on type identity.","message":"PyPEG2 uses Python's `str` as a base class for `Symbol`, which means that parsed values become strings. Be careful with type checks and comparisons.","severity":"gotcha","affected_versions":"all"},{"fix":"Consider using alternative PEG parser generators like `parsimonious` or `lark-parser` for new projects.","message":"The `pypeg2` library is not actively maintained and may have compatibility issues with newer Python versions (e.g., Python 3.10+).","severity":"deprecated","affected_versions":"2.15.2"},{"fix":"Always use `attr` to define fields; the order of tuple elements defines the parse order.","message":"Grammar definitions using tuples and `attr` can be confusing. Order of elements in tuple matters for parsing sequence.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install correct package: `pip install pypeg2` and use `from pypeg2 import parse`.","cause":"Incorrect import; installed `pypeg` instead of `pypeg2`.","error":"AttributeError: module 'pypeg2' has no attribute 'parse'"},{"fix":"Parse result is an object with attributes; use dot notation like `result.name.first`.","cause":"Treating a parsed `Symbol` as a tuple/list instead of accessing its attributes.","error":"TypeError: 'Symbol' object does not support indexing"},{"fix":"Use correct import: `from pypeg2 import Parser` (capital P).","cause":"Typo in import; correct symbol is `Parser` but some older documentation shows `parser` (lowercase).","error":"ImportError: cannot import name 'Parser' from 'pypeg2'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}