summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Lexer.h
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-13 17:36:38 +0100
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-01-13 17:36:38 +0100
commit058a18c612c6d4f33779058b07ba80b3854f2275 (patch)
tree6fcb75fb0ba30fc6104e83863aa93f3e15375c1e /Sencha-lang/Lexer.h
parent837d4c4bce813919f6713f76c7c24404951751f6 (diff)
downloadsencha-lang-master.tar.gz
sencha-lang-master.tar.bz2
sencha-lang-master.zip
More documentaaaaation.HEADmaster
Diffstat (limited to 'Sencha-lang/Lexer.h')
-rw-r--r--Sencha-lang/Lexer.h48
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