Open MarcosCosmos opened 7 years ago
I guess this could be done with #IMPORT <FILE>
. Shouldn't be too hard once the code gets cleaned up a bit. Will need a separate function for reading the files. Something like fn read_from<R: BufRead>(&mut self, from: &mut R)
on a Context
struct or so, which holds the current rendering state like colors, variables, etc.
pretty much what I had in mind - although my instinct is to have the reader be a seperate function rather than a member function. Couple of considerations:
If we want to potentially support nested contexts, then it should be a member method, though?
We could also have the Context
as a struct without any methods on it, then pass it wherever it's needed. The alternative would be to put the variables and macros in the reader, which feels ugly to me.
So, something like this:
struct Context {
variables: BTreeMap<String, String>, // or whatever other representation we will use for variables
macros: BTreeMap<String, Macro>
}
Fairly straight forward, importing from other files helps with #12 as we can all just share a repo of definitions for each game.
Debatable: