diff options
author | Jessie Speert <speer034@umn.edu> | 2021-03-08 19:09:55 -0800 |
---|---|---|
committer | Jessie Speert <speer034@umn.edu> | 2021-03-08 19:09:55 -0800 |
commit | f30fcc505dc3ce2df25dce16b329c90c32049862 (patch) | |
tree | 88e51f09844d0df1627643ccc3a1335d5fd74cbf /dev/a4-dance/simple_parser.h | |
parent | Added Assignment 3 worksheet and code (diff) | |
download | csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.gz csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.bz2 csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.lz csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.xz csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.tar.zst csci4611-f30fcc505dc3ce2df25dce16b329c90c32049862.zip |
Uploading Assignment 4
Diffstat (limited to 'dev/a4-dance/simple_parser.h')
-rw-r--r-- | dev/a4-dance/simple_parser.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/dev/a4-dance/simple_parser.h b/dev/a4-dance/simple_parser.h new file mode 100644 index 0000000..b077b43 --- /dev/null +++ b/dev/a4-dance/simple_parser.h @@ -0,0 +1,42 @@ +#ifndef SIMPLE_PARSER_H_ +#define SIMPLE_PARSER_H_ + +#include <fstream> +#include <string> + +/** Helper class for parsing text input. */ +class SimpleParser { +public: + SimpleParser(std::istream *i); + + bool Expect(std::string s); + + bool Peek(std::string s); + + void SwallowWhitespace(); + + void SwallowLine(); + + bool ReadFloat(float &f); + + bool ReadInt(int &i); + + bool ReadToken(std::string &s); + + bool Good(); + + bool ReadLine(std::string &line); + + bool UpcomingInt(); + +protected: + bool FloatChar(char c); + + bool IntChar(char c); + + bool TokenChar(char c); + + std::istream *in_; +}; + +#endif |