コード例 #1
0
ファイル: DFAGen.cs プロジェクト: sgtFloyd/rit_coursework
    static void Main(string[] args)
    {
        String fileNameIn = "";
        String fileNameOut = "";
        Boolean debugMode = false;

        // Parse command line options
        if ( args.Length == 3 && args[0].Equals("-d")) {
            debugMode = true;
            fileNameIn = args[1];
            fileNameOut = args[2];
        } else if ( args.Length == 2 ) {
            fileNameIn = args[0];
            fileNameOut = args[1];
        } else {
            Console.WriteLine("Usage: DFAGen [-d] DFAProgramFile C#ClassName"); return;
        }

        // create file reader
        TextReader reader = null;
        try {
            reader = File.OpenText( fileNameIn );
        } catch (Exception e) {
            Console.WriteLine("File Error:  " + e.Message);
            return;
        }

        DFAScanner scanner = new DFAScanner(reader);
        DFAParser parser = new DFAParser(scanner);
        parser.setDebug(debugMode);
        parser.parse();

        // write out the generated file
        parser.outputToFile( fileNameOut );
    }
コード例 #2
0
ファイル: DFAParser.cs プロジェクト: sgtFloyd/rit_coursework
 /**
  * Create a new parser that reads from the specified scanner.
  *
  * @param s the scanner from which tokens are to be read.
  */
 public DFAParser( DFAScanner s )
 {
     this.s = s;
     debug = false;
 }