{"id":27849,"library":"gramforge","title":"gramforge","description":"gramforge is a Python library for efficient multi-language generation from context-free or context-sensitive grammars (CFG/CSG). It supports generating strings and structures from grammar definitions, suitable for tasks like fuzzing, test generation, and language prototyping. Current version is 1.0.9, with a stable release cadence.","status":"active","version":"1.0.9","language":"python","source_language":"en","source_url":"https://github.com/gramforge/gramforge","tags":["grammar","generation","CFG","CSG","fuzzing"],"install":[{"cmd":"pip install gramforge","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"Grammar is not a top-level module; import from gramforge","wrong":"import Grammar","symbol":"Grammar","correct":"from gramforge import Grammar"},{"note":"Generator is directly accessible from the main package","wrong":"from gramforge.generator import Generator","symbol":"Generator","correct":"from gramforge import Generator"}],"quickstart":{"code":"from gramforge import Grammar, Generator\n\n# Define a simple grammar\ngrammar = Grammar.from_string('''\nS = 'Hello ' Name\nName = 'world' | 'Alice' | 'Bob'\n''')\n\n# Create a generator\ngen = Generator(grammar)\n\n# Generate a string\nresult = gen.generate()\nprint(result)  # e.g., 'Hello world'\n","lang":"python","description":"Defines a grammar and generates a string from it."},"warnings":[{"fix":"Refer to the official documentation for grammar syntax (e.g., S = 'hello' Name).","message":"Grammar syntax is custom and not compatible with common grammar formats (e.g., ANTLR, EBNF). Double-check the format for rules and terminals.","severity":"gotcha","affected_versions":"all"},{"fix":"Use gen = Generator(grammar, seed=42) for reproducible output.","message":"The generator is not deterministic unless explicitly seeded. Repeated calls to generate() may yield different outputs.","severity":"gotcha","affected_versions":"all"},{"fix":"Wrap in try-except: try: grammar = Grammar.from_string(rule) except Exception as e: print(e).","message":"Grammar.from_string() may raise ParseError for malformed rules. Always catch exceptions when processing dynamic grammars.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Run 'pip install gramforge' in the correct Python environment.","cause":"Package not installed or installed in wrong environment.","error":"ModuleNotFoundError: No module named 'gramforge'"},{"fix":"Use 'from gramforge import Grammar' instead of 'import gramforge'.","cause":"Wrong import path; user tried to import 'gramforge' then access Grammar.","error":"AttributeError: module 'gramforge' has no attribute 'Grammar'"},{"fix":"Check grammar rules: each production should be like 'NonTerminal = ...'.","cause":"Grammar rule syntax error, e.g., missing '=' or incorrect formatting.","error":"gramforge.grammar.ParseError: Expected '='"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}