// Path: Mouse/source/runtime/SourceFile.java
// public class SourceFile implements Source
// {
//   //=====================================================================
//   //
//   //  Data.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  The file.
//   //-------------------------------------------------------------------
//   private File f;
// 
//   //-------------------------------------------------------------------
//   //  Memory-mapped file.
//   //-------------------------------------------------------------------
//   private String text;
// 
//   //-------------------------------------------------------------------
//   //  Character encoding assumed for the file.
//   //  To use encoding other than default, change as shown
//   //  in the commented-out example.
//   //-------------------------------------------------------------------
//   private static final Charset cs = Charset.defaultCharset();
//   // static final Charset cs = Charset.forName("8859_1");
// 
//   //-------------------------------------------------------------------
//   //  Success indicator.
//   //-------------------------------------------------------------------
//   private boolean created = false;
// 
// 
//   //=====================================================================
//   //
//   //  Constructor. Wraps the file identified by 'fileName'.
//   //
//   //=====================================================================
//   public SourceFile(final String fileName)
//     {
//       try
//       {
//         // Get a Channel for the source file
//         f = new File(fileName);
//         FileInputStream fis = new FileInputStream(f);
//         FileChannel fc = fis.getChannel();
// 
//         // Get a CharBuffer from the source file
//         ByteBuffer bb =
//             fc.map(FileChannel.MapMode.READ_ONLY, 0, (int)fc.size());
//         CharsetDecoder cd = cs.newDecoder();
//         CharBuffer cb = cd.decode(bb);
//         fis.close();
// 
//         // Convert to String
//         text = cb.toString();
//         created = true;
//       }
//       catch (FileNotFoundException e)
//       { System.err.println("File '" + fileName + "' was not found."); }
//       catch (IOException e)
//       { System.err.println("Error in file '" + fileName + "' " + e.getMessage()); }
//     }
// 
// 
//   //=====================================================================
//   //
//   //  Interface methods.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  Is the wrapper correctly initialized?
//   //-------------------------------------------------------------------
//   public boolean created()
//     { return created; }
// 
//   //-------------------------------------------------------------------
//   //  Returns end position.
//   //-------------------------------------------------------------------
//   public int end()
//     { return text.length(); }
// 
//   //-------------------------------------------------------------------
//   //  Returns character at position p.
//   //-------------------------------------------------------------------
//   public char at(int p)
//     { return text.charAt(p); }
// 
//   //-------------------------------------------------------------------
//   //  Returns characters at positions p through q-1.
//   //-------------------------------------------------------------------
//   public String at(int p, int q)
//     { return text.substring(p,q); }
// 
//   //-------------------------------------------------------------------
//   //  Describes position p in terms of line and column number.
//   //  Lines and columns are numbered starting with 1.
//   //-------------------------------------------------------------------
//   public String where(int p)
//     {
//       int ln = 1;   // Line number
//       int ls = -1;  // Line start (position of preceding newline)
//       int nextnl;   // Position of next newline or end
// 
//       while (true)
//       {
//         nextnl = text.indexOf('\n',ls+1);
//         if (nextnl<0) nextnl = text.length();
//         if (ls<p && p<=nextnl)
//           return ("line " + ln + " col. " + (p-ls));
//         ls = nextnl;
//         ln++;
//       }
//     }
// 
//   //=====================================================================
//   //
//   //  File-specific method.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  Returns the file object.
//   //-------------------------------------------------------------------
//   public File file()
//     { return f; }
// }


import mouse.runtime.SourceFile;



class FileCalc
{
  public static void main(String argv[])
    {
      myParser parser = new myParser();          // Instantiate Parser+Semantics

// Path: Mouse/source/runtime/SourceFile.java
// public class SourceFile implements Source
// {
//   //=====================================================================
//   //
//   //  Data.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  The file.
//   //-------------------------------------------------------------------
//   private File f;
// 
//   //-------------------------------------------------------------------
//   //  Memory-mapped file.
//   //-------------------------------------------------------------------
//   private String text;
// 
//   //-------------------------------------------------------------------
//   //  Character encoding assumed for the file.
//   //  To use encoding other than default, change as shown
//   //  in the commented-out example.
//   //-------------------------------------------------------------------
//   private static final Charset cs = Charset.defaultCharset();
//   // static final Charset cs = Charset.forName("8859_1");
// 
//   //-------------------------------------------------------------------
//   //  Success indicator.
//   //-------------------------------------------------------------------
//   private boolean created = false;
// 
// 
//   //=====================================================================
//   //
//   //  Constructor. Wraps the file identified by 'fileName'.
//   //
//   //=====================================================================
//   public SourceFile(final String fileName)
//     {
//       try
//       {
//         // Get a Channel for the source file
//         f = new File(fileName);
//         FileInputStream fis = new FileInputStream(f);
//         FileChannel fc = fis.getChannel();
// 
//         // Get a CharBuffer from the source file
//         ByteBuffer bb =
//             fc.map(FileChannel.MapMode.READ_ONLY, 0, (int)fc.size());
//         CharsetDecoder cd = cs.newDecoder();
//         CharBuffer cb = cd.decode(bb);
//         fis.close();
// 
//         // Convert to String
//         text = cb.toString();
//         created = true;
//       }
//       catch (FileNotFoundException e)
//       { System.err.println("File '" + fileName + "' was not found."); }
//       catch (IOException e)
//       { System.err.println("Error in file '" + fileName + "' " + e.getMessage()); }
//     }
// 
// 
//   //=====================================================================
//   //
//   //  Interface methods.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  Is the wrapper correctly initialized?
//   //-------------------------------------------------------------------
//   public boolean created()
//     { return created; }
// 
//   //-------------------------------------------------------------------
//   //  Returns end position.
//   //-------------------------------------------------------------------
//   public int end()
//     { return text.length(); }
// 
//   //-------------------------------------------------------------------
//   //  Returns character at position p.
//   //-------------------------------------------------------------------
//   public char at(int p)
//     { return text.charAt(p); }
// 
//   //-------------------------------------------------------------------
//   //  Returns characters at positions p through q-1.
//   //-------------------------------------------------------------------
//   public String at(int p, int q)
//     { return text.substring(p,q); }
// 
//   //-------------------------------------------------------------------
//   //  Describes position p in terms of line and column number.
//   //  Lines and columns are numbered starting with 1.
//   //-------------------------------------------------------------------
//   public String where(int p)
//     {
//       int ln = 1;   // Line number
//       int ls = -1;  // Line start (position of preceding newline)
//       int nextnl;   // Position of next newline or end
// 
//       while (true)
//       {
//         nextnl = text.indexOf('\n',ls+1);
//         if (nextnl<0) nextnl = text.length();
//         if (ls<p && p<=nextnl)
//           return ("line " + ln + " col. " + (p-ls));
//         ls = nextnl;
//         ln++;
//       }
//     }
// 
//   //=====================================================================
//   //
//   //  File-specific method.
//   //
//   //=====================================================================
//   //-------------------------------------------------------------------
//   //  Returns the file object.
//   //-------------------------------------------------------------------
//   public File file()
//     { return f; }
// }


// Path: Mouse/examples/example9/FileCalc.java
import mouse.runtime.SourceFile;



class FileCalc
{
  public static void main(String argv[])
    {
      myParser parser = new myParser();          // Instantiate Parser+Semantics

      SourceFile src = new SourceFile(argv[0]);  // Wrap the file
