So, I think it depends on what you want out of the tag system. If you want it to be a global tag that tags a post similar to how they’re used on tumblr or something like that (I.E: Has meaning not specific to the community it is in), that should be separate from per-community tags, like they’re done on reddit.
I think per-community tags should definitely be added, similar to how reddit does them (for a good example of how they are used, see /r/talesfromtechsupport). Global tags, I’m not as sure, and if they are added, I think they should be separate from the per-community ones.
My hesitation for the global tags is that it will create meta-communities, similar to what happens on tumblr, which blurs the line between communities, which makes moderation a little weird.
Storing an AST would be interesting, but it’d require the IDE to support parsing each specific language, so you’d probably want something like an LSP but for just parsing to handle that.