示例#1
0
 /// <summary>Reinitializes the object. This method is called by the constructor.</summary>
 /// <remarks>
 /// See the constructor for documentation of the parameters.
 /// <para/>
 /// This method can be used to avoid memory allocations when you
 /// need to parse many small strings in a row. If that's your goal, you
 /// should set the <c>newSourceFile</c> parameter to false if possible.</remarks>
 public virtual void Reset(CharSrc chars, string fileName = "", int inputPosition = 0, bool newSourceFile = true)
 {
     CheckParam.IsNotNull <object>("source", chars);
     _charSource   = chars;
     _fileName     = fileName;
     _block        = UString.Empty;
     InputPosition = inputPosition;
     _lineNumber   = 1;
     _lineStartAt  = inputPosition;
     if (newSourceFile)
     {
         _sourceFile = new LexerSourceFile <CharSrc>(chars, fileName);
     }
     else
     {
         _sourceFile = null;
     }
 }
示例#2
0
 /// <summary>Reinitializes BaseLexer, as if you called the constructor again.</summary>
 protected virtual void Reset(ICharSource source, string fileName = "", int inputPosition = 0, bool newSourceFile = true)
 {
     CheckParam.IsNotNull("source", source);
     _source       = source;
     _fileName     = fileName;
     _block        = UString.Empty;
     InputPosition = inputPosition;
     _lineNumber   = 1;
     _lineStartAt  = inputPosition;
     if (newSourceFile)
     {
         _sourceFile = new LexerSourceFile(source, fileName);
     }
     else
     {
         _sourceFile = null;
     }
 }