How thisisthedarshan/pss-grammar works
Project type and purpose
• This is an open-source tooling repository whose sole purpose is to define, build, and distribute parsers for the Portable Stimulus Standard (PSS).
• It provides two parallel grammar pipelines: one for ANTLR4 (in ANTLR4/v3/) and one for Tree-sitter (described in the README, typically under TreeSitter/v3/).
File structure
• Top-level:
• README.md, LICENSE – project overview and license.
• ANTLR4/ – directory containing ANTLR4 grammar files.
– v3/ – version-3 grammars broken out by language feature (e.g., expressions.g4, data_types.g4, etc.).
– README.md – build instructions for ANTLR4.
• (Implicit per README) TreeSitter/v3/ – Tree-sitter grammar definitions and build scripts.
• No application code, runtime, or UI here—only grammar definitions and build instructions.
README for additional insights
• Describes two build pipelines:
• ANTLR4: you run antlr4 pss.g4 in ANTLR4/v3/ to generate parser/lexer code.
• Tree-sitter: you initialize, generate, compile with tree-sitter-cli and gcc -shared.
• Targets multiple output languages via ANTLR4’s code generators and Tree-sitter’s language bindings.
a. Main components
1. Input: PSS language specification (the Accellera LRM).
2. Grammar source modules:
– ANTLR4 grammars (.g4 files under ANTLR4/v3/).
– Tree-sitter grammar files under TreeSitter/v3/ (per README).
3. Generator tools:
– ANTLR4 CLI tool.
– Tree-sitter CLI tool & C compiler.
4. Generated artifacts:
– Parser & lexer source code in target languages (Java, Python, C#, etc.).
– Shared library (parser.so) for Tree-sitter.
5. Consumers / Integration points:
– Host projects embedding the generated parsers.
– IDEs or editor plugins using the Tree-sitter grammar.
– CI pipelines that test grammar correctness against sample PSS code.
b. Relationships & interactions
c. Architectural patterns & principles
• Separation of concerns: grammar definition vs. parser generation vs. integration.
• Modular grammar: each .g4 is a slice of the language, combined by ANTLR4.
• Dual-pipeline architecture: two parallel build flows for different parser frameworks.
• Polyglot codegen support: multiple target languages configured in one grammar repo.
d. Key technologies & libraries
• ANTLR4 grammar files (*.g4) + ANTLR4 CLI
• Tree-sitter grammar JS + tree-sitter-cli, GCC
• Generated language runtimes: Java, Python, C#, JavaScript/TypeScript, Go, C++ etc.
• Node.js (for Tree-sitter initialization)