No description
  • JavaScript 94.6%
  • Scheme 5.4%
Find a file
2025-11-07 22:29:35 +01:00
bindings Parses sophistication and highlighting 2025-11-01 23:41:00 +01:00
queries More highlights that work better 2025-11-07 22:24:02 +01:00
src Regenerated the parser 2025-11-07 22:29:35 +01:00
test/corpus Fixed math parsing 2025-11-01 23:41:00 +01:00
.editorconfig initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
.gitattributes initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
.gitignore initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
binding.gyp initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
Cargo.toml Results of tree-parser generate 2025-11-01 23:41:00 +01:00
CMakeLists.txt Results of tree-parser generate 2025-11-01 23:41:00 +01:00
go.mod initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
grammar.js Updated grammar with some edge cases that I wasn't catching 2025-11-07 22:23:15 +01:00
LICENSE add AGPL 3 license file 2025-10-31 20:59:23 +01:00
Makefile Results of tree-parser generate 2025-11-01 23:41:00 +01:00
package.json Results of tree-parser generate 2025-11-01 23:41:00 +01:00
Package.swift initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
pyproject.toml Results of tree-parser generate 2025-11-01 23:41:00 +01:00
README.md Parser changed and readme expanded 2025-10-31 22:19:48 +01:00
setup.py initial setup after running tree-sitter init 2025-10-31 14:12:48 +01:00
tree-sitter.json Parses sophistication and highlighting 2025-11-01 23:41:00 +01:00
uv.lock updated uv.lock 2025-11-07 22:21:40 +01:00

Introduction

When I was exploring my options for modding Stellaris I made some conclusions, one of which was that I wanted all sorts of things that boiled down to "merge with less bullshit". mergiraf can do nice merging, but I need a tree-sitter grammar for the language they use. That is PDXScript, which has no formal syntax definition and while there are some bespoke tools for working with it (the most well-known is cwtools) they don't define a grammar in a way I can use for this. So I have to make one myself.

Current state

Workability

It parses pdxscript-based objects well enough, I tested a few 3-way merges of ascension perks of popular mods in mergiraf. It'll be really irritating to use for highlighting as it doesn't have a very good idea of what things are keywords inside of known classes (e.g. ai_weight, triggered_modifier). This is also why it is palatable for trivial merge cases (e.g. weird adds, order changes or stacked variable changes are no problem) but currently isn't capable of processing merges in files that add two "identical" "variables". One such case is on_enabled inside of ascension perks. I'm pretty sure that you can have more than one, but it doesn't work very well for that right now.

Language definition for mergiraf

If you want to give it a try, this is the language definition I used for mergiraf:

LangProfile {
    name: "PDXScript",
    alternate_names: &["pdx", "pdxscript"],
    extensions: vec!["txt"],
    file_names: vec![],
    language: tree_sitter_pdxscript::LANGUAGE.into(),
    atomic_nodes: vec![],
    commutative_parents: vec![
        CommutativeParent::new("block", "{", "", "}"),
        CommutativeParent::without_delimiters("source_file", "\n"),
    ],
    signatures: vec![signature("variable_definition", vec![vec![Field("name")]])],
    injections: None,
    flattened_nodes: &[],
    comment_nodes: &[],
},

You will also need to add something like this (under [dependencies]) to mergiraf's Cargo.toml:

tree-sitter-pdxscript = { git = "https://git.sr.ht/~canteen/tree-sitter-pdxscript" }

If you make local changes or something like that I'm pretty sure you can make it look at a directory too. That's all outlined in the cargo reference.

Plans

  • Add keywords to parser
  • Make mergiraf not break on multiple on_enabled keys
  • Make a proper merge request so this gets added to mergiraf

I want to add keywords to the parser and make it so that mergiraf is more chill with them or merges the contents of blocks under identical keywords. Can't imagine it isn't already capable of doing so, I probably just fucked it up somehow.