To me it seems you want to deal with the rules of grammars (contextfree, context-sensitive, whatever) which are e.g. also used for designing programming languages.
Then you could define rules for which spells might follow which other spells or which modifiers. This is checked on syntax (correctness according to the rules) first.
Grammars look like this (I will not make it as formal as it is usually, because it might frighten you)
- We always start with
- We can replace
- We can also replace
[spell], [spell] (making to spells in a row)
- We can replace
- We can repeat these rules several times
This would be a valid grammar and say we have the following basic_spells: fire, water, light
And these modifiers (sizeof): small, big, short, long
We could do something like this:
small fire, long water
small fire, water
But illegal would be something like
big short water. Or also
angry fire, because there is no word
angry in our set.
Of course you can replace the long words with single characters.
Later you will have to check it for semantics (meaning), e.g. if somebody uses a fire spell and then a water spell, it would reduce the overall power of the spell (Baten Kaitos uses this system). So
big fire, small water would reduce the power of this spell, because water stops fire.
One the whole you could search for how programming languages are designed, because creating a new syntax for spells is nothing different. Maybe start with finding out how brainfuck works and search for how compilers or interpreters for brainfuck are programmed. As far as I know it's usually a few steps:
- checking if all characters are valid
- checking if the order of characters and words is valid (e.g.
foo int is not valid in Java, but
int foo is)
- building a tree from the code
- traversing that tree to generate the basic commands (in your case the desired spell combination)
Might not be totally correct, as I am not a compiler-programmer.
Depending on how difficult your syntax shall be, you can leave out some of the commands. E.g. my upper example was totally linear. You only had to check if the spell is valid and if it was, combine adjectives and nouns and then execute all commands in a row.
But in programming languages we also have
if-conditions and loops (
while), which leads to non-linear situations. Thus we need a tree which shows us how stuff is related.
In your situation one could think of spells like
4($!) which might mean: Do the spell
$! four times.
So you see, it's pretty much parsing a programming language.