The Open Papyrus Project (OPP) provides open source grammars that describe the Papyrus language. This language is used by Bethesda Softworks and authors of mods for games such as The Elder Scrolls V: Skyrim and Fallout 4.
This project's intent is to facilitate the development of language tools — such as syntax highlighting, inspections, refactorings, code clone analysis, and build automation — by producing accurate and efficient grammars.
Currently, this project consists of only the lexer and parser grammars for Papyrus scripts and the flags file.
These grammars were ported from the ANTLR3 .NET implementations to ANTLR4 grammars. They are based on the implementations for Fallout 4, which is assumed to implicitly describe Papyrus for Skyrim.
Work has not yet started on the following grammars:
- Papyrus Type Walker
- Papyrus Release and Final Processor
- Papyrus Optimizer
- Papyrus Var Cleaner
- Papyrus Code Generator
The available grammars have not been fully tested.
The compiler makes use of each grammar in the following order:
- Loads and parses scripts into objects (
PapyrusParser
) - Creates a dictionary of parsed flags (
FlagsParser
) - Checks for type safety (
PapyrusTypeWalker
) - Performs release and final processing (
PapyrusReleaseProcessor
) - Optimizes expressions (
PapyrusOptimizer
) - Cleans up temporary and unused variables (
PapyrusVarCleaner
) - Builds final tree and formats data with string template (
PapyrusGen
)
The compiler then passes control to the assembler which writes .pex
output.
Grammar contributions and testing are appreciated. Here's how to get started:
- Install PyCharm. A free Community Edition is available.
- Install the ANTLR v4 and StringTemplate v4 plugins.
- Use the ANTLR Preview tool to test and profile rules.
For developers, submit pull requests. For everyone else, submit issues.
The Open Papyrus Project is not affiliated, endorsed, or authorized by ZeniMax Media, Bethesda Softworks, or Microsoft in any way.