123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- #ifndef _PCRE_SCANNER_H
- #define _PCRE_SCANNER_H
- #include <assert.h>
- #include <string>
- #include <vector>
- #include <pcrecpp.h>
- #include <pcre_stringpiece.h>
- namespace pcrecpp {
- class PCRECPP_EXP_DEFN Scanner {
- public:
- Scanner();
- explicit Scanner(const std::string& input);
- ~Scanner();
-
-
-
-
-
- int LineNumber() const;
-
-
- int Offset() const;
-
- bool LookingAt(const RE& re) const;
-
-
-
-
-
-
- bool Consume(const RE& re,
- const Arg& arg0 = RE::no_arg,
- const Arg& arg1 = RE::no_arg,
- const Arg& arg2 = RE::no_arg
-
- );
-
-
-
-
-
-
-
-
-
-
-
-
-
- void Skip(const char* re);
- void SetSkipExpression(const char* re);
-
-
-
-
-
- void DisableSkip();
-
-
- void EnableSkip();
-
-
-
-
-
-
-
- void SkipCXXComments() {
- SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/");
- }
- void set_save_comments(bool comments) {
- save_comments_ = comments;
- }
- bool save_comments() {
- return save_comments_;
- }
-
-
-
-
-
- void GetComments(int start, int end, std::vector<StringPiece> *ranges);
-
-
-
-
- void GetNextComments(std::vector<StringPiece> *ranges);
- private:
- std::string data_;
- StringPiece input_;
- RE* skip_;
- bool should_skip_;
- bool skip_repeat_;
- bool save_comments_;
-
-
-
- std::vector<StringPiece> *comments_;
-
- int comments_offset_;
-
-
- void ConsumeSkip();
- };
- }
- #endif
|