Recommended way of adding grammar from outside the .cson file


I’m currently making a package for garry’s mod, but its api adds thousands of lua functions and I don’t really want to define them inline in the .cson file. So I want to, for example, parse a .xml file that has all the definitions in there and build the grammar from that.

I found that there are these grammar and grammarRegistry classes in the API, but there weren’t any usage examples for what I’m trying to do.

I’m worried that I mess stuff up and would love to just extend my grammar.cson in a way.
Does anyone know a good way of going about it?