Ejemplo n.º 1
0
Archivo: Calc.cs Proyecto: Domer79/Calc
 public static Scanner MultiplyOrDivide(this Scanner scanner)
 {
     return(scanner.Pipe(new MultiplyDividePattern(scanner)));
 }
Ejemplo n.º 2
0
Archivo: Calc.cs Proyecto: Domer79/Calc
 public static Scanner AddOrSubtract(this Scanner scanner)
 {
     return(scanner.Pipe(new AddSubtractPattern(scanner)));
 }
Ejemplo n.º 3
0
Archivo: Calc.cs Proyecto: Domer79/Calc
 public static Scanner Brackets(this Scanner scanner)
 {
     return(scanner.Pipe(new BracketsPattern(scanner)));
 }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            bool   mergeErrors = false;
            string inputName   = null;

            // ------------------------ you may need to process command line parameters:

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToLower().Equals("-l"))
                {
                    mergeErrors = true;
                }
                else
                {
                    inputName = args[i];
                }
            }
            if (inputName == null)
            {
                Console.WriteLine("No input file specified");
                System.Environment.Exit(1);
            }

            int pos = inputName.LastIndexOf('/');

            if (pos < 0)
            {
                pos = inputName.LastIndexOf('\\');
            }
            string dir = inputName.Substring(0, pos + 1);

/*++++ If the parser needs an output file, include a section like the following
 *     and add a line
 *
 *          public static OutFile output;
 *
 *     to your ATG file.
 *
 *    string outputName = null;
 *    pos = inputName.LastIndexOf('.');
 *    if (pos < 0) outputName = inputName + ".out";
 *    else outputName = inputName.Substring(0, pos) + ".out";
 *    Parser.output = new OutFile(outputName);
 *    if (Parser.output.OpenError()) {
 *      Console.WriteLine("cannot open " + outputName);
 *      System.Environment.Exit(1);
 *    }
 *
 ++++++ */

            Scanner.Init(inputName);
            Errors.Init(inputName, dir, mergeErrors);
            //  ----------------------- add other initialization if required:
            Parser.Parse();
            Errors.Summarize();
            //  ----------------------- add other finalization if required:

/*++++ If the parser needs an output file, uncomment this section
 *    Parser.output.Close();
 ++++++ */
        }