diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-11-01 14:39:34 -0500 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-11-01 14:39:34 -0500 |
commit | 36b8bde22e15e7a8608bd8920b4d6d8edf78af18 (patch) | |
tree | 1c022ce8d1854c6120ed492eb0bcad2e016e0f1f /dev/a4-dance/simple_parser.h | |
parent | do a3 (diff) | |
parent | Update a4_dance.md (diff) | |
download | csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar.gz csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar.bz2 csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar.lz csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar.xz csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.tar.zst csci4611-36b8bde22e15e7a8608bd8920b4d6d8edf78af18.zip |
Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/shared-upstream
Diffstat (limited to '')
-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 |