diff options
Diffstat (limited to 'Sencha-lang/Lexer.h')
-rw-r--r-- | Sencha-lang/Lexer.h | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/Sencha-lang/Lexer.h b/Sencha-lang/Lexer.h index cd3db82..d94f708 100644 --- a/Sencha-lang/Lexer.h +++ b/Sencha-lang/Lexer.h @@ -9,31 +9,39 @@ using namespace std;
+/**
+ * Lexer is a class which gets some text, analyzes it and returns a vector of tokens.
+ */
class Lexer
{
- public:
- Lexer();
- virtual ~Lexer(); - - void add_keyword(string word); - void add_punctuation_char(char c); - void add_operator(string oper); - string unescape_string(string text);
- - vector<Token> parse_line(string line); - pair<string, Token> parse_token(string line); - type_of_token guess_type(string value); +public:
+ Lexer();
+ virtual ~Lexer();
+ /**
+ * parse_line(line) analyzes input and returns vector of tokens.
+ */ + vector<Token> parse_line(string line);
+ pair<string, Token> parse_token(string line);
+
+ //helper function to evaluate type of token
+ bool is_keyword(string value);
+ bool is_punctuation(char c);
+ bool is_operator(string value ); - bool is_keyword(string value);
- bool is_punctuation(char c);
- bool is_operator(string value );
+private:
+ void add_keyword(string word);
+ void add_punctuation_char(char c);
+ void add_operator(string oper);
+ string unescape_string(string text);
- protected:
- private: + /**
+ * Tokens have type and value. Type is evaluated in function guess_type(value).
+ */
+ type_of_token guess_type(string value);
- vector<string> keywords; - vector<char> punctuation; - vector<string> operators;
+ vector<string> keywords; + vector<char> punctuation; + vector<string> operators;
};
#endif // LEXER_H
|