Skip to content

Loading…

How to include one citrus grammar in another... #12

Closed
lightscalar opened this Issue · 2 comments

2 participants

@lightscalar

Is it possible to include one Citrus grammar in another, if the grammar exists in a separate file? I cannot seem to "require" the citrus file. If two grammars are in the same file, I can successfully include one in the other. But if I want to store one in a different file, is it possible to somehow require it?

@mjackson
Owner

For now I've been using a combination of Module#autoload and Citrus.load to accomplish this. For example, in one file I'll declare my top level module with an autoload instruction for each segment of the grammar that I want to load. Then, in the autoloaded file I just use Citrus.load to actually load that module from a .citrus file somewhere, usually in the same directory but with a different suffix.

I realize that this is a bit hacky and is sort of a roundabout solution. Perhaps we could hijack require when used in a .citrus file. First, try the normal Kernel#require but rescue a LoadError and try to use Citrus.load. What do you think? Any other ideas?

@mjackson
Owner

I've added the ability for Citrus files to require one another in this commit. Closing this issue.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.