|Shopping Cart Download Website|
|You are here: 8051 Tools Code Library Lexer|
Fixed String LexerDon't like reading docs? Why not just Skip Down to the Code?
What is it, What's it good for?This simple fixed string lexer searches for any number of fixed strings of any length (with some limitations) in a stream of characters. Each string may be a different length, and it's pretty easy to add strings to the list or to change the string texts it will detect.
The most likely use for this simple lexer is an 8051 based system which receives commands from a computer, probably while performing other tasks. This lexer allows you to easily implement several multiple character command words in your project/product. The lexer is designed to return control quickly... no waiting for more data once the first part of a string is detected... no failure to recognize any complete command because part of another command was only partially received.
Many 8051 based projects can't spare much CPU time (or perhaps the designer's time and effort)... the typical solution seems to be single character command sets. This code uses relatively few CPU cycles and should be quite easy to use. Hopefully you won't have to resort to single character command sets unless that's what you really wanted.
Limitations(under construction... if you need help, just ask)
Briefly, here's the limitations:
Can't recognize numbers, parameters, etc... string must be fixed when you assemble the code.
Finds overlapping and inclusive strings... command set design must be chosen carefully to avoid problems.
No error checking on your strings, string lengths, etc
Strings limited to 255 bytes long, each needs one byte of internal ram, thus limiting the number that can be included in the search list.
Can't deal with backspace.
Some code customization necessary, see the comments in the code for details.