News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Parsing, part 5: wrap-up

Started by NoCforMe, September 19, 2022, 04:05:41 AM

Previous topic - Next topic

NoCforMe

Now that my parsing method is out there, I just wanted to give a closing synopsis to this series. The image below shows the overall scheme of how all the pieces of this puzzle fit together. As we've seen, all the code (and the all-important data) for a parser using this technique is pretty compact.

A couple of details worth mentioning:

1. If you use this scheme to parse text, either from a file or from, say, an edit control for user input, you need to make sure that there's an EOF (end of file) marker at the end of that text. I use -1 as a signal value, since that'll never be seen in normal ANSI text. If you're parsing the contents of an edit control you could use the terminating zero at the end instead. (Or you could put a zero at the end of your file buffer.) I make an EQUate defining the EOF character for easy reference.

2. I store all the data I extract from the text--strings, identifiers, numbers--globally, in known locations. You could do this, or you could return the data locally from the main parsing function if you prefer that way of doing things. I find that global data is (usually) much easier to deal with, but your mileage may vary.

If you decide to try this technique out, be sure to have fun with it! And let us know what you did.
Assembly language programming should be fun. That's why I do it.