Skip to content

Reimplement XSLT pattern matching inside the stack-based VM#126

Open
bojidar-bg wants to merge 1 commit intoPaligo:mainfrom
bojidar-bg:refactor-templates
Open

Reimplement XSLT pattern matching inside the stack-based VM#126
bojidar-bg wants to merge 1 commit intoPaligo:mainfrom
bojidar-bg:refactor-templates

Conversation

@bojidar-bg
Copy link
Contributor

The current implementation of ir::ApplyTemplates is very rigid, making it hard to run any XPath code before the XSLT pattern-matching engine takes over.
After #123 (comment) and plenty of thinking, I've come to the conclusion that the best way forward is to reimplement ir::ApplyTemplates without using instruction::ApplyTemplates and Program.declarations, so that ir::Declarations can now become a "normal" IR instruction, ir::DefineTemplates.
This should allow for a very easy implementation of root-level xsl:param-s, xsl:variables-s, and xsl:functions-s, as they can use the whole of the IR implementation, without us having to re-implement parts of it for each global feature in the spec.

(I have not fully investigated how this will impact packages, but I imagine that since packages' modes are private by default, having them split into multiple per-package ir::DefineTemplates groups will potentially be helpful once we get there.)

Would welcome early feedback of the work so far.
I'll be working on splitting and cleaning the new function_compiler.rs code in the coming days.

Now, instruction::ApplyTemplates has been replaced with the leaner instruction::MatchPattern, which in turn allows for a much simpler implementation of xsl:param root-level declarations.
Also, implement `#current` mode with a ClosureVar because it's easy. 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant