// Path: Mouse/source/runtime/Source.java
// public interface Source
// {
//   //-------------------------------------------------------------------
//   //  Is the wrapper correctly initialized?
//   //  The wrapper's constructor may encounter errors that result
//   //  in the object not being properly initialized.
//   //  The method returns 'false' if this is the case.
//   //-------------------------------------------------------------------
//   boolean created();
// 
//   //-------------------------------------------------------------------
//   //  Returns position of the last character plus 1
//   //  (= length of the sequence).
//   //-------------------------------------------------------------------
//   int end();
// 
//   //-------------------------------------------------------------------
//   //  Returns character at position p.
//   //-------------------------------------------------------------------
//   char at(int p);
// 
//   //-------------------------------------------------------------------
//   //  Returns characters at positions p through q-1.
//   //-------------------------------------------------------------------
//   String at(int p, int q);
// 
//   //-------------------------------------------------------------------
//   //  Describes position p in user's terms.
//   //-------------------------------------------------------------------
//   String where(int p);
// }


import mouse.runtime.Source;
import java.util.Vector;
//=========================================================================
//
//  Part of PEG parser generator Mouse.
//
//  Copyright (C) 2009, 2010, 2011, 2012
//  by Roman R. Redziejowski (www.romanredz.se).
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
//-------------------------------------------------------------------------
//
//  Change log
//
//   090720 Created for Mouse 1.1.
//  Version 1.2
//   100320 Bug fix in accept(): upgrade error info on success.
//   100320 Bug fix in rejectNot(): backtrack before registering failure.
//  Version 1.3
//   100429 Bug fix in errMerge(Phrase): assignment to errText replaced
//          by clear + addAll (assignment produced alias resulting in
//          explosion of errText in memo version).
//   101105 Changed errMerge(msg,pos) to errAdd(who).
//   101105 Commented error handling.
//   101129 Added 'boolReject'.
//   101203 Convert result of 'listErr' to printable.
//  Version 1.4
//   110918 Changed 'listErr' to separate 'not' texts as 'not expected'.
//   111004 Added methods to implement ^[s].
//   111004 Implemented method 'where' of Phrase.
//  Version 1.5
//   111027 Revised methods for ^[s] and ^[c].
//   111104 Implemented methods 'rule' and 'isTerm' of Phrase.
//  Version 1.5.1
//   120102 (Steve Owens) Ensure failure() method does not emit blank
//          line when error info is absent.
//  Version 1.6
//   120130 rhsText: return empty string for empty range.
//
//=========================================================================

package mouse.runtime;



//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//
//  ParserBase
//
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH


public class ParserBase implements mouse.runtime.CurrentRule
{
  //-------------------------------------------------------------------
  //  Input
  //-------------------------------------------------------------------
// Path: Mouse/source/runtime/Source.java
// public interface Source
// {
//   //-------------------------------------------------------------------
//   //  Is the wrapper correctly initialized?
//   //  The wrapper's constructor may encounter errors that result
//   //  in the object not being properly initialized.
//   //  The method returns 'false' if this is the case.
//   //-------------------------------------------------------------------
//   boolean created();
// 
//   //-------------------------------------------------------------------
//   //  Returns position of the last character plus 1
//   //  (= length of the sequence).
//   //-------------------------------------------------------------------
//   int end();
// 
//   //-------------------------------------------------------------------
//   //  Returns character at position p.
//   //-------------------------------------------------------------------
//   char at(int p);
// 
//   //-------------------------------------------------------------------
//   //  Returns characters at positions p through q-1.
//   //-------------------------------------------------------------------
//   String at(int p, int q);
// 
//   //-------------------------------------------------------------------
//   //  Describes position p in user's terms.
//   //-------------------------------------------------------------------
//   String where(int p);
// }


// Path: Mouse/source/runtime/ParserBase.java
import mouse.runtime.Source;
import java.util.Vector;

//=========================================================================
//
//  Part of PEG parser generator Mouse.
//
//  Copyright (C) 2009, 2010, 2011, 2012
//  by Roman R. Redziejowski (www.romanredz.se).
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
//-------------------------------------------------------------------------
//
//  Change log
//
//   090720 Created for Mouse 1.1.
//  Version 1.2
//   100320 Bug fix in accept(): upgrade error info on success.
//   100320 Bug fix in rejectNot(): backtrack before registering failure.
//  Version 1.3
//   100429 Bug fix in errMerge(Phrase): assignment to errText replaced
//          by clear + addAll (assignment produced alias resulting in
//          explosion of errText in memo version).
//   101105 Changed errMerge(msg,pos) to errAdd(who).
//   101105 Commented error handling.
//   101129 Added 'boolReject'.
//   101203 Convert result of 'listErr' to printable.
//  Version 1.4
//   110918 Changed 'listErr' to separate 'not' texts as 'not expected'.
//   111004 Added methods to implement ^[s].
//   111004 Implemented method 'where' of Phrase.
//  Version 1.5
//   111027 Revised methods for ^[s] and ^[c].
//   111104 Implemented methods 'rule' and 'isTerm' of Phrase.
//  Version 1.5.1
//   120102 (Steve Owens) Ensure failure() method does not emit blank
//          line when error info is absent.
//  Version 1.6
//   120130 rhsText: return empty string for empty range.
//
//=========================================================================

package mouse.runtime;



//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
//
//  ParserBase
//
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH


public class ParserBase implements mouse.runtime.CurrentRule
{
  //-------------------------------------------------------------------
  //  Input
  //-------------------------------------------------------------------
  Source source;                    // Source of text to parse