Quick Strings....

I'm developing my first compiler (yeehaa), and I'm looking

for a fast way to clasify the users commands, I was just wondering

If you guys knew another way other than strcmp()...


TNX. Anyone


Comments

  • I don't mean to be patronizing, but using a strcmp-like function to interpret commands is not the proper way of doing things. I would suggest that you look into things like Bison and Flex.


    More importantly than that, however, I suggest you read some material on compiler design. This is one of those rare computer science problems that, at its core anyway, can safely be labled as solved. If you can, I suggest you read the "Dragon Book" (also known as 'Compilers: Principles, Techniques, and Tools' ISBN 0-201-10088-6). It is basically the best place to find this sort of information. If you prefer something a little less complicated, try reading some of the articles at http://www-cs-students.stanford.edu/~amitp/gameprog.html#Languages . The eight-part series and the gamasutra articles are good. The eight part series also allows you to download tools like I mentioned earlier. These articles are basically guides to implementing a byte code/virtual machine based language to be interpreted from within a game. It sounds like you want to produce real machine code from your compiler, but it is not so hard to convert intermediate code (it will make more sense when you read the material) into machine code.


    If you have alread read this stuff and I just misinterpreted your post, I apoligize. If you want faster string searching than strcmp(), then you should use a Boyer-Moore string searching based approach. Go to http://wannabe.guru.org/alg/ for more information. At that site there is also a fair amount on formal languages, so you should check that out if I didn't misinterpret you question :)


    I, too, am making a compiler. Or I should say I already made the compiler, it is just the interpreter that I can't get working properly just yet. Actually, I am making a slightly improper language, but despite the fact that the language is essentially a taged text format, the tags are converted to proper byte code. I must warn you that making even a weak and only slightly useful language, like the one I made, is _very_ time consuming. I wish you the best of luck.


    Hope some of this helps,

    -Raynor


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories