Plot Script
token.hpp
Go to the documentation of this file.
1 
4 #ifndef TOKEN_HPP
5 #define TOKEN_HPP
6 
7 #include <deque>
8 #include <istream>
9 
15 class Token {
16 public:
17 
21  enum TokenType { OPEN, //< open tag, aka '('
22  CLOSE, //< close tag, aka ')'
23  STRING //< string tag
24  };
25 
27  Token(TokenType t);
28 
30  Token(const std::string & str);
31 
33  TokenType type() const;
34 
36  std::string asString() const;
37 
38 private:
39  TokenType m_type;
40  std::string value;
41 };
42 
47 typedef std::deque<Token> TokenSequenceType;
48 
60 TokenSequenceType tokenize(std::istream & seq);
61 
62 #endif
TokenType
a public enum defining the possible token types.
Definition: token.hpp:21
std::string asString() const
return the token rendered as a string
Definition: token.cpp:20
Token(TokenType t)
construct a token of type t (if string default to empty value)
Definition: token.cpp:12
Value class representing a token.
Definition: token.hpp:15
TokenSequenceType tokenize(std::istream &seq)
Split a stream into a sequnce of tokens.
Definition: token.cpp:40
std::deque< Token > TokenSequenceType
Definition: token.hpp:47
Definition: token.hpp:21
Definition: token.hpp:23
TokenType type() const
return the type of the token
Definition: token.cpp:16
Definition: token.hpp:22