The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: travism on November 02, 2008, 03:51:56 AM

Title: String parsing tutoria anywhere?
Post by: travism on November 02, 2008, 03:51:56 AM
Is there a string parsing tutorial anywhere? Im getting so frustrated everything I want to make needs insane amounts of it.. :( Yet Ive tried/read so many things yet nothing makes since is there one anywhere or a program anywhere with alot of it in it to try and understand it?
Title: Re: String parsing tutoria anywhere?
Post by: hutch-- on November 02, 2008, 05:06:22 AM
Travis,

Its a reasonably complicated area but there are a number of string functions/macros in the masm32 library that can do many common things. You can write either unicode 2 byte characters or the older ANSI/ASCII style depending on what you are doing and essentially you are reading/comparing one character at a time and in most instances with a terminating zero to know the end of the string. The exception is strings of known length like OLE string.

Give us some idea of what you are doing and we may be able to help you but to address your original question, I don't know of a bare string parser tutorial as the area is very diverse.
Title: Re: String parsing tutoria anywhere?
Post by: travism on November 02, 2008, 06:20:31 AM
Well I wrote my own scripting language in C, and ofcourse as you might be able to tell it takes alot of string parsing, for instance reading in a file word by word and parsing out certain bytes so for instance like

putscr ("Hello, World");

needs to read in putscr and then parse out Hello, World.

so kind of an idea.. And then I wanted to start making some apps that use command line stuff but then that is just returned as a string so i would have to parse that too..
Title: Re: String parsing tutoria anywhere?
Post by: hutch-- on November 02, 2008, 07:20:56 AM
have a look at the two tokenisers in the MASM32 library, it will give you some idea of how to tokenise either words or lines in assembler. A slightly smarter one handles broken lines but you must devise a way to track the line numbers for error reporting.
Title: Re: String parsing tutorial anywhere?
Post by: Mark Jones on November 02, 2008, 03:14:22 PM
Also, here is some fully-commented code showing how ASCII .ini file data can be "parsed." This isn't especially tidy or efficient, but it is helpful for understanding. (Scroll down to the GetPrivateProfileStringML routine.)

http://www.masm32.com/board/index.php?topic=1073.0

It is much more productive to follow along with the code when it is actually running -- put that proc in a test piece and call it, then load the executable into OllyDbg (http://ollydbg.de/) and press F7 repeatedly to step through each instruction. :U