/[pcre]/code/trunk/pcre_scanner.h
ViewVC logotype

Diff of /code/trunk/pcre_scanner.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 77 by nigel, Sat Feb 24 21:40:45 2007 UTC revision 93 by nigel, Sat Feb 24 21:41:42 2007 UTC
# Line 36  Line 36 
36  //      Scanner scanner(input);  //      Scanner scanner(input);
37  //      string var;  //      string var;
38  //      int number;  //      int number;
39  //      scanner.Skip("\\s+");           // Skip any white space we encounter  //      scanner.SetSkipExpression("\\s+"); // Skip any white space we encounter
40  //      while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) {  //      while (scanner.Consume("(\\w+) = (\\d+)", &var, &number)) {
41  //        ...;  //        ...;
42  //      }  //      }
# Line 90  class Scanner { Line 90  class Scanner {
90    // skipped.  For example, a programming language scanner would use    // skipped.  For example, a programming language scanner would use
91    // a skip RE that matches white space and comments.    // a skip RE that matches white space and comments.
92    //    //
93    //    scanner.Skip("(\\s|//.*|/[*](.|\n)*?[*]/)*");    //    scanner.SetSkipExpression("\\s+|//.*|/[*](.|\n)*?[*]/");
94      //
95      // Skipping repeats as long as it succeeds.  We used to let people do
96      // this by writing "(...)*" in the regular expression, but that added
97      // up to lots of recursive calls within the pcre library, so now we
98      // control repetition explicitly via the function call API.
99    //    //
100    // You can pass NULL for "re" if you do not want any data to be skipped.    // You can pass NULL for "re" if you do not want any data to be skipped.
101    void Skip(const char* re);    void Skip(const char* re);   // DEPRECATED; does *not* repeat
102      void SetSkipExpression(const char* re);
103    
104    // Temporarily pause "skip"ing. This    // Temporarily pause "skip"ing. This
105    //   Skip("Foo"); code ; DisableSkip(); code; EnableSkip()    //   Skip("Foo"); code ; DisableSkip(); code; EnableSkip()
# Line 109  class Scanner { Line 115  class Scanner {
115    /***** Special wrappers around SetSkip() for some common idioms *****/    /***** Special wrappers around SetSkip() for some common idioms *****/
116    
117    // Arranges to skip whitespace, C comments, C++ comments.    // Arranges to skip whitespace, C comments, C++ comments.
118    // The overall RE is a repeated disjunction of the following REs:    // The overall RE is a disjunction of the following REs:
119    //    \\s                     whitespace    //    \\s                     whitespace
120    //    //.*\n                  C++ comment    //    //.*\n                  C++ comment
121    //    /[*](.|\n)*?[*]/        C comment (x*? means minimal repetitions of x)    //    /[*](.|\n)*?[*]/        C comment (x*? means minimal repetitions of x)
122      // We get repetition via the semantics of SetSkipExpression, not by using *
123    void SkipCXXComments() {    void SkipCXXComments() {
124      Skip("((\\s|//.*\n|/[*](.|\n)*?[*]/)*)");      SetSkipExpression("\\s|//.*\n|/[*](?:\n|.)*?[*]/");
125    }    }
126    
127    void set_save_comments(bool comments) {    void set_save_comments(bool comments) {
# Line 143  class Scanner { Line 150  class Scanner {
150    StringPiece   input_;         // Unprocessed input    StringPiece   input_;         // Unprocessed input
151    RE*           skip_;          // If non-NULL, RE for skipping input    RE*           skip_;          // If non-NULL, RE for skipping input
152    bool          should_skip_;   // If true, use skip_    bool          should_skip_;   // If true, use skip_
153      bool          skip_repeat_;   // If true, repeat skip_ as long as it works
154    bool          save_comments_; // If true, aggregate the skip expression    bool          save_comments_; // If true, aggregate the skip expression
155    
156    // the skipped comments    // the skipped comments

Legend:
Removed from v.77  
changed lines
  Added in v.93

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12