Jump to content
Posted 14 July 2011 - 02:59 PM
Posted 14 July 2011 - 03:31 PM
Posted 14 July 2011 - 04:27 PM
Posted 14 July 2011 - 04:46 PM
Posted 14 July 2011 - 05:38 PM
Posted 14 July 2011 - 06:39 PM
alnite, thanks, I've though about how regex would help me here and toyed with the idea of using pcre which seems fairly popular (C++ doesn't really have regex out of the box yet, I think tr1 has them though), I think I will have a use for it when it comes to parse numeric tokens/values/parameters, but for mapping function calls to CLI instructions, I really see no advantage... yet. What I am constructing is some sort of trie/radix tree, taking advantage of the O (log n) performance std::map provides.
Feel free to provide input though .
Posted 14 July 2011 - 07:46 PM
Insert all your instructions into a long string delimited by a special character: "|apple|apricot|avocado|banana"
Then perform your regex search.
Posted 14 July 2011 - 10:49 PM
Posted 14 July 2011 - 11:57 PM
Posted 18 July 2011 - 11:51 AM
Posted 18 July 2011 - 03:47 PM
You could split on spaces with in commands and store hash tokens as the key elements of the Trie, this would only be beneficial however if you support many multi word commands.
Yeah, I got to this point after going through the trie idea and then PATRICIA, which this would be if I was splitting each word (ap, pple, ricot), then again if you take the words as the unit rather than characters, then it probably is.
I don't care that much about memory though (~32kb - 100kb is way less than a texture takes nowadays), and I doubt the extra work to split words and then putting them back together is that much worth it, I might try it later though.