From 12b0b74d43b7d93eee82ae6fa3dced499cd8a1f6 Mon Sep 17 00:00:00 2001 From: KT Date: Tue, 19 Oct 2021 14:03:28 -0500 Subject: Publish a4 --- dev/a4-dance/simple_parser.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dev/a4-dance/simple_parser.h (limited to 'dev/a4-dance/simple_parser.h') 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 +#include + +/** 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 -- cgit v1.2.3