KrisLibrary
1.0.0
|
A simple class to break files into tokens, punctuation, comments, and whitespace. More...
#include <SimpleParser.h>
Public Types | |
enum | Result { Continue, Stop, Error } |
Public Attributes | |
istream & | in |
int | lineno |
A simple class to break files into tokens, punctuation, comments, and whitespace.
Non-comment lines are broken up into tokens and punctuation, possibly separated by whitespace. Tokens and punctuation are contiguous blocks of token and punctuation characters.
Comments take up an entire line. The format is whitespace, followed by comment char, and consumes characters up to the endline.
Whitespace, comment, token, and punctuation characters are determined by the overrideable IsSpace, IsComment, IsToken, and IsPunct methods. By default, tokens are alphanumeric characters, whitespaces are spaces, tabs, and newlines, and comments start with '#'. Punctuation is everything else.
Callbacks are defined by overriding InputToken, InputPunct, and InputEndline in a subclass. They can return Continue to continue reading the file, Stop to stop reading the file (with success), and Error to stop reading the file with failiure.