protected static void AddSemanticError(ErrorHandler errs, string message, Position pos, ErrorSeverity severity) { if (pos != null) { errs.AddError(string.Format("Semantic error on line {0}: {1}", pos.StartLine, message), pos, severity); } else { errs.AddError(string.Format("Semantic error: {0}", message), null, severity); } }
/// <summary> /// This is the method that computes the shortest terminal /// string sequence for each NonTerminal symbol. The immediate /// guide is to find those NT that are non-terminating. /// </summary> void MarkTerminating() { bool changed = false; int nonTerminatingCount = 0; // This uses a naive algorithm that iterates until // an iteration completes without changing anything. do { changed = false; nonTerminatingCount = 0; foreach (KeyValuePair <string, NonTerminal> kvp in this.nonTerminals) { NonTerminal nonTerm = kvp.Value; if (!nonTerm.terminating) { foreach (Production prod in nonTerm.productions) { if (ProductionTerminates(prod)) { nonTerm.terminating = true; changed = true; } } if (!nonTerm.terminating) { nonTerminatingCount++; } } } } while (changed); // // Now produce some helpful diagnostics. // We wish to find single NonTerminals that, if made // terminating will fix up many, even all of the // non-terminating NonTerminals that have been found. // if (nonTerminatingCount > 0) { List <NonTerminal> ntDependencies = BuildDependencyGraph(); hasNonTerminatingNonTerms = true; handler.AddError( 5, String.Format(CultureInfo.InvariantCulture, "There are {0} non-terminating NonTerminal Symbols{1} {{{2}}}", nonTerminatingCount, System.Environment.NewLine, ListUtilities.GetStringFromList(ntDependencies)), null); FindNonTerminatingSCC(ntDependencies); // Do some diagnosis } }
public override void yyerror(string format, params object[] args) { if (yyhdlr != null) { LexSpan span = TokenSpan(); if (args == null || args.Length == 0) { yyhdlr.AddError(2, format, span); } else { yyhdlr.AddError(3, String.Format(CultureInfo.InvariantCulture, format, args), span); } } }
public async Task <VidPackModel.Session> LoadNextSession() { Session nextSession = new Session(); try { nextSession = (await _mobileService.GetTable <ExistingSession>().ReadAsync()) .Where(item => item.IsActualSession == 1) .Select(item => new Session { SessionDate = item.SessionDate.ToString(), SessionDescription = item.SessionDescription, SessionSubTitle = item.SessionSubTitle, SessionThumbnailDisplayUrl = item.SessionThumbnailUri, SessionThumbnailUrl = item.SessionThumbnailUri, SessionTitle = item.SessionTitle, SessionVideoUrl = item.SessionVideoUri, }).FirstOrDefault(); } catch (Exception exception) { ErrorHandler.AddError(exception); } return(nextSession); }
// ============================================================================= #endregion Terminating Computation // ============================================================================= internal bool CheckGrammar(ErrorHandler handler) { bool ok = true; NonTerminal nt; this.handler = handler; MarkReachable(); MarkTerminating(); foreach (KeyValuePair <string, NonTerminal> pair in nonTerminals) { nt = pair.Value; if (!nt.reached) { handler.AddWarning(152, String.Format(CultureInfo.InvariantCulture, "NonTerminal symbol \"{0}\" is unreachable", pair.Key), null); } if (nt.productions.Count == 0) { ok = false; handler.AddError(5, String.Format(CultureInfo.InvariantCulture, "NonTerminal symbol \"{0}\" has no productions", pair.Key), null); } } if (this.HasNonTerminatingNonTerms) { ok = false; } return(ok); }
FileStream FrameFile() { FileStream frameFile = null; string path1 = this.userFrame; try { // Try the user-specified path if there is one given. frameFile = new FileStream(path1, FileMode.Open, FileAccess.Read, FileShare.Read); if (verbose) { msgWrtr.WriteLine("GPLEX: opened frame file <{0}>", path1); } this.frameName = path1; return(frameFile); } catch (IOException) { // This is a fatal error. handler.AddError("GPLEX frame file <" + path1 + "> not found", aast.AtStart); return(null); } }
/// <summary> /// This method opens the source file. The file is not disposed in this file. /// The mainline code (program.cs) can call MakeListing and/or ErrorReport, for /// which the buffered stream needs to be open so as to interleave error messages /// with the source. /// </summary> internal void OpenSource() { try { inputFile = new FileStream(this.pathName, FileMode.Open, FileAccess.Read, FileShare.Read); if (verbose) { msgWrtr.WriteLine("GPLEX: opened input file <{0}>", pathName); } } catch (IOException) { inputFile = null; handler = new ErrorHandler(); // To stop handler.ErrNum faulting! string message = String.Format(CultureInfo.InvariantCulture, "Source file <{0}> not found{1}", fileName, Environment.NewLine); handler.AddError(message, null); // aast.AtStart; throw new ArgumentException(message); } }
public async Task <List <Session> > LoadPastSession() { string serviceEndpoint = "session"; List <Session> returnValue = new List <Session>(); try { using (HttpClient httpClient = new HttpClient()) { Uri uri = new Uri(string.Format("{0}{1}", _webServiceUri, serviceEndpoint)); string jsonResult = await httpClient.GetStringAsync(uri); returnValue = Deserialize <List <Session> >(jsonResult); } } catch (HttpRequestException exception) { ErrorHandler.AddError(exception); } return(returnValue); }
public async Task <Session> LoadNextSession() { string serviceEndpoint = "nextsession"; Session returnValue = new Session(); try { using (HttpClient httpClient = new HttpClient()) { Uri uri = new Uri(string.Format("{0}{1}", _webServiceUri, serviceEndpoint)); JObject jsonResult = JObject.Parse(await httpClient.GetStringAsync(uri)); returnValue = jsonResult.ToObject <Session>(); } } catch (HttpRequestException exception) { ErrorHandler.AddError(exception); } return(returnValue); }
internal void Process(string fileArg) { GetNames(fileArg); // check for file exists OpenSource(); // parse source file if (inputFile != null) { DateTime start = DateTime.Now; try { handler = new ErrorHandler(); scanner = new QUT.Gplex.Lexer.Scanner(inputFile); parser = new QUT.Gplex.Parser.Parser(scanner); scanner.yyhdlr = handler; parser.Initialize(this, scanner, handler, new OptionParser2(ParseOption)); aast = parser.Aast; parser.Parse(); // aast.DiagnosticDump(); if (verbose) Status(start); CheckOptions(); if (!Errors && !ParseOnly) { // build NFSA if (ChrClasses) { DateTime t0 = DateTime.Now; partition = new Partition( TargetSymCardinality, this ); partition.FindClasses( aast ); partition.FixMap(); if (verbose) ClassStatus( t0, partition.Length ); } else CharRange.Init( TargetSymCardinality ); nfsa = new NFSA(this); nfsa.Build(aast); if (!Errors) { // convert to DFSA dfsa = new DFSA(this); dfsa.Convert(nfsa); if (!Errors) { // minimize automaton if (minimize) dfsa.Minimize(); if (!Errors && !checkOnly) { // emit the scanner to output file TextReader frameRdr = FrameReader(); TextWriter outputWrtr = OutputWriter(); dfsa.EmitScanner(frameRdr, outputWrtr); if (!embedBuffers) CopyBufferCode(); // Clean up! if (frameRdr != null) frameRdr.Close(); if (outputWrtr != null) outputWrtr.Close(); } } } } } catch (Exception ex) { string str = ex.Message; handler.AddError(str, aast.AtStart); throw; } } }
/// <summary> /// This method opens the source file. The file is not disposed in this file. /// The mainline code (program.cs) can call MakeListing and/or ErrorReport, for /// which the buffered stream needs to be open so as to interleave error messages /// with the source. /// </summary> internal void OpenSource() { try { inputFile = new FileStream(this.pathName, FileMode.Open, FileAccess.Read, FileShare.Read); if (verbose) msgWrtr.WriteLine("GPLEX: opened input file <{0}>", pathName); inputInfo = this.pathName + " - " + File.GetLastWriteTime(this.pathName).ToString(); } catch (IOException) { inputFile = null; handler = new ErrorHandler(); // To stop handler.ErrNum faulting! string message = String.Format(CultureInfo.InvariantCulture, "Source file <{0}> not found{1}", fileName, Environment.NewLine); handler.AddError(message, null); // aast.AtStart; throw new ArgumentException(message); } }
private void CheckAllErrors() { string check_client_file = laucherSettings.GetClientLocation() + @"\" + laucherSettings.GetClientFilename() + ".exe"; if (!File.Exists(check_client_file)) { ErrorHandler.AddError(ErrorType.error_Client_noLocation); } string check_server_file = laucherSettings.GetServerLocation() + @"\" + laucherSettings.GetServerFilename() + ".exe"; if (!File.Exists(check_server_file)) { ErrorHandler.AddError(ErrorType.error_Server_noLocation); } DisplayErrors(); }
internal void Process(string fileArg) { GetNames(fileArg); // check for file exists OpenSource(); // parse source file if (inputFile != null) { DateTime start = DateTime.Now; try { handler = new ErrorHandler(); scanner = new QUT.Gplex.Lexer.Scanner(inputFile); parser = new QUT.Gplex.Parser.Parser(scanner); scanner.yyhdlr = handler; parser.Initialize(this, scanner, handler, new OptionParser2(ParseOption)); aast = parser.Aast; parser.Parse(); // aast.DiagnosticDump(); if (verbose) { Status(start); } CheckOptions(); if (!Errors && !ParseOnly) { // build NFSA if (ChrClasses) { DateTime t0 = DateTime.Now; partition = new Partition(TargetSymCardinality, this); partition.FindClasses(aast); partition.FixMap(); if (verbose) { ClassStatus(t0, partition.Length); } } else { CharRange.Init(TargetSymCardinality); } nfsa = new NFSA(this); nfsa.Build(aast); if (!Errors) { // convert to DFSA dfsa = new DFSA(this); dfsa.Convert(nfsa); if (!Errors) { // minimize automaton if (minimize) { dfsa.Minimize(); } if (!Errors && !checkOnly) { // emit the scanner to output file TextReader frameRdr = FrameReader(); TextWriter outputWrtr = OutputWriter(); dfsa.EmitScanner(frameRdr, outputWrtr); if (!embedBuffers) { CopyBufferCode(); } // Clean up! if (frameRdr != null) { frameRdr.Close(); } if (outputWrtr != null) { outputWrtr.Close(); } } } } } } catch (Exception ex) { string str = ex.Message; handler.AddError(str, aast.AtStart); throw; } } }
private static int Main( string[] args ) { Stream inputFile = null; Grammar grammar = null; ErrorHandler handler = new ErrorHandler(); string inputFileInfo = null; // Filename plus revision time. Lexers.Scanner scanner = null; Parser.Parser parser = null; Assembly assm = Assembly.GetExecutingAssembly(); object info = Attribute.GetCustomAttribute( assm, typeof( AssemblyFileVersionAttribute ) ); versionInfo = ((AssemblyFileVersionAttribute)info).Version; try { string filename = ProcessOptions( args ); if (filename == null) return MC_OK; try { inputFile = new FileStream( filename, FileMode.Open, FileAccess.Read, FileShare.Read ); inputFileInfo = filename + " - " + File.GetLastWriteTime( filename ).ToString(); } catch (IOException x) { string message; inputFile = null; if (x is FileNotFoundException) message = String.Format( CultureInfo.InvariantCulture, "Source file <{0}> not found{1}", filename, Environment.NewLine ); else message = String.Format( CultureInfo.InvariantCulture, "Source file <{0}> could not be opened{1}", filename, Environment.NewLine ); handler.AddError( 4, message, null ); // aast.AtStart; return MC_FILEERROR; } scanner = new Lexers.Scanner( inputFile ); scanner.SetHandler( handler ); parser = new Parser.Parser( filename, inputFileInfo, scanner, handler ); // // If the parse is successful, then process the grammar. // Otherwise just report the errors that have been listed. // if (parser.Parse()) { grammar = parser.Grammar; if (Terminal.Max > 255) handler.ListError( null, 103, CharacterUtilities.Map( Terminal.Max ), '\'' ); LALRGenerator generator = new LALRGenerator( grammar ); List<AutomatonState> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar( handler )) throw new ArgumentException( "Non-terminating grammar" ); // // If the grammar has non-terminating non-terms we cannot // create a diagnostic report as the grammar is incomplete. // if (!handler.Errors) { CodeGenerator code = new CodeGenerator(); code.Generate( states, grammar ); } bool DoDiagnose = Diagnose && !grammar.HasNonTerminatingNonTerms; if (Report || DoDiagnose) { string htmlName = System.IO.Path.ChangeExtension( filename, ".report.html" ); try { System.IO.FileStream htmlFile = new System.IO.FileStream( htmlName, System.IO.FileMode.Create ); System.IO.StreamWriter htmlWriter = new System.IO.StreamWriter( htmlFile ); Grammar.HtmlHeader( htmlWriter, filename ); if (Report && DoDiagnose) grammar.GenerateCompoundReport( htmlWriter, inputFileInfo, states ); else if (Report) grammar.GenerateReport( htmlWriter, inputFileInfo, states ); Grammar.HtmlTrailer( htmlWriter ); if (htmlFile != null) { htmlWriter.Flush(); htmlFile.Close(); } } catch (System.IO.IOException) { Console.Error.WriteLine( "Cannot create html output file {0}", htmlName ); } } } } catch (System.Exception e) { if (e is TooManyErrorsException) return MC_TOOMANYERRORS; Console.Error.WriteLine( "Unexpected Error {0}", e.Message ); if (NoThrowOnError) { // report the error, do not let it go into the void Console.Error.WriteLine( e ); return MC_EXCEPTION; } } finally { if (handler.Errors || handler.Warnings) handler.DumpAll( (scanner == null ? null : scanner.Buffer), Console.Error ); if ((Listing || handler.Errors || handler.Warnings) && parser != null) { string listName = parser.ListfileName; StreamWriter listStream = ListingFile( listName ); if (listStream != null) handler.MakeListing( scanner.Buffer, listStream, parser.SourceFileInfo, versionInfo ); } } return MC_OK; }
private static int Main(string[] args) { args = new[] { "/report", "/verbose", "/conflicts", "/babel", "SpecFiles\\BrightScript.y" }; Stream inputFile = null; Grammar grammar = null; ErrorHandler handler = new ErrorHandler(); string inputFileInfo = null; // Filename plus revision time. Scanner scanner = null; Parser parser = null; Assembly assm = Assembly.GetExecutingAssembly(); object info = Attribute.GetCustomAttribute(assm, typeof(AssemblyFileVersionAttribute)); versionInfo = ((AssemblyFileVersionAttribute)info).Version; try { string filename = ProcessOptions(args); if (filename == null) { return(MC_OK); } try { inputFile = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); inputFileInfo = filename + " - " + File.GetLastWriteTime(filename).ToString(); } catch (IOException x) { string message; inputFile = null; if (x is FileNotFoundException) { message = String.Format(CultureInfo.InvariantCulture, "Source file <{0}> not found{1}", filename, Environment.NewLine); } else { message = String.Format(CultureInfo.InvariantCulture, "Source file <{0}> could not be opened{1}", filename, Environment.NewLine); } handler.AddError(4, message, null); // aast.AtStart; return(MC_FILEERROR); } scanner = new Scanner(inputFile); scanner.SetHandler(handler); parser = new Parser(filename, inputFileInfo, scanner, handler); // // If the parse is successful, then process the grammar. // Otherwise just report the errors that have been listed. // if (parser.Parse() && !handler.Errors) { grammar = parser.Grammar; if (Terminal.Max > 255) { // No ambiguating context possible since result appears in delimited error message handler.ListError(null, 103, CharacterUtilities.MapCodepointToDisplayForm(Terminal.Max), '\''); } LALRGenerator generator = new LALRGenerator(grammar); List <AutomatonState> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar()) { throw new ArgumentException("Non-terminating grammar"); } // // If the grammar has non-terminating non-terms we cannot // create a diagnostic report as the grammar is incomplete. // if (!handler.Errors) { CodeGenerator emitter = new CodeGenerator(grammar); emitter.Generate(states); } bool DoDiagnose = Diagnose && !grammar.HasNonTerminatingNonTerms; if (Report || DoDiagnose) { string htmlName = System.IO.Path.ChangeExtension(filename, ".report.html"); try { System.IO.FileStream htmlFile = new System.IO.FileStream(htmlName, System.IO.FileMode.Create); System.IO.StreamWriter htmlWriter = new System.IO.StreamWriter(htmlFile); Grammar.HtmlHeader(htmlWriter, filename); if (Report && DoDiagnose) { grammar.GenerateCompoundReport(htmlWriter, inputFileInfo, states); } else if (Report) { grammar.GenerateReport(htmlWriter, inputFileInfo, states); } Grammar.HtmlTrailer(htmlWriter); if (htmlFile != null) { htmlWriter.Flush(); htmlFile.Close(); } } catch (System.IO.IOException) { Console.Error.WriteLine("Cannot create html output file {0}", htmlName); } } } } catch (System.Exception e) { if (e is TooManyErrorsException) { return(MC_TOOMANYERRORS); } Console.Error.WriteLine("Unexpected Error {0}", e.Message); if (NoThrowOnError) { // report the error, do not let it go into the void Console.Error.WriteLine(e); return(MC_EXCEPTION); } } finally { if (handler.Errors || handler.Warnings) { handler.DumpAll((scanner == null ? null : scanner.Buffer), Console.Error); } if ((Listing || handler.Errors || handler.Warnings) && parser != null) { string listName = parser.ListfileName; StreamWriter listStream = ListingFile(listName); if (listStream != null) { handler.MakeListing(scanner.Buffer, listStream, parser.SourceFileInfo, versionInfo); } } Console.WriteLine("Press any enter to close"); Console.ReadLine(); } return(MC_OK); }
public async Task <List <VidPackModel.Session> > LoadPastSession() { List <Session> actualSession; #region - Mobile Service "Traditional" - //actualSession = (await _mobileService.GetTable<ExistingSession>().ReadAsync()) // .Select(item => new Session // { // Id = item.Id, // SessionDate = item.SessionDate.ToString(), // SessionDescription = item.SessionDescription, // SessionSubTitle = item.SessionSubTitle, // SessionThumbnailDisplayUrl = item.SessionThumbnailUri, // SessionThumbnailUrl = item.SessionThumbnailUri, // SessionTitle = item.SessionTitle, // SessionVideoUrl = item.SessionVideoUri, // }).ToList<Session>(); //#region - Mobile Service "Traditional" Child Records - //foreach (Session session in actualSession) //{ // session.SessionDownloadItem = (await _mobileService.GetTable<MobileServiceDataType.DownloadItem>().Where(item => item.ExistingSession_Id == session.Id) // .Select(item => new DownloadItemInfo() { // Caption = item.Caption, // Description = item.Description, // Url = item.Url, // }) // .ToListAsync()); //} //#endregion - Mobile Service "Traditional" Child Records - #endregion - Mobile Service "Traditional"- #region - Mobile Service "VTable" - //var sessionRawInfo = (await _mobileService.GetTable<V_ExistingSession_DownloadItem>().ToListAsync()); //var sessionGrouped = sessionRawInfo.GroupBy(p => p.SessionDescription, p => p, // (key, g) => new // { // SessionTitle = g.ToList()[0].SessionTitle, // SessionSubTitle = g.ToList()[0].SessionSubTitle, // SessionDate = g.ToList()[0].SessionDate, // Speaker = g.ToList()[0].Speaker, // SessionDescription = g.ToList()[0].SessionDescription, // SessionVideoUri = g.ToList()[0].SessionVideoUri, // SessionThumbnailUrl = g.ToList()[0].SessionThumbnailUri, // SessionThumbnailDisplayUrl = "ms-appx:///Assets/SessionPlaceholder.jpg", // IsActualSession = g.ToList()[0].IsActualSession, // IsNextSession = g.ToList()[0].IsNextSession, // DownloadItems = g.ToList().Select(item => new // { // Caption = item.Caption, // Description = item.Description, // Url = item.Url // }).ToList(), // }).ToList(); //actualSession = sessionGrouped.Select(item => new Session() //{ // SessionDate = item.SessionDate.ToString(), // SessionDescription = item.SessionDescription, // SessionSubTitle = item.SessionSubTitle, // SessionThumbnailDisplayUrl = item.SessionThumbnailDisplayUrl, // SessionThumbnailUrl = item.SessionThumbnailUrl, // SessionTitle = item.SessionTitle, // SessionVideoUrl = item.SessionVideoUri, // Speaker = item.Speaker, // SessionDownloadItem = item.DownloadItems.Select(_ => new DownloadItemInfo() // { // Caption = _.Caption, // Description = _.Description, // Url = _.Url, // }).ToList<DownloadItemInfo>(), //}).ToList<Session>(); //Get json Info //JToken jToken = (await _mobileService.GetTable("V_ExistingSession_DownloadItem").ReadAsync("")); //var sessions = jToken.ToObject<List<V_ExistingSession_DownloadItem>>(); #endregion - Mobile Service "VTable" - #region - Mobile Service API - var arguments = new Dictionary <string, string>(); List <V_ExistingSession_DownloadItem> sessionRawInfoApi = new List <V_ExistingSession_DownloadItem>(); try { sessionRawInfoApi = (await _mobileService.InvokeApiAsync <List <V_ExistingSession_DownloadItem> >("v_existingsession_downloaditem", HttpMethod.Get, arguments)); } catch (Exception exception) { ErrorHandler.AddError(exception); return(new List <Session>()); } var sessionGroupedApi = sessionRawInfoApi.GroupBy(p => p.SessionDescription, p => p, (key, g) => new { SessionTitle = g.ToList()[0].SessionTitle, SessionSubTitle = g.ToList()[0].SessionSubTitle, SessionDate = g.ToList()[0].SessionDate, Speaker = g.ToList()[0].Speaker, SessionDescription = g.ToList()[0].SessionDescription, SessionVideoUri = g.ToList()[0].SessionVideoUri, SessionThumbnailUrl = g.ToList()[0].SessionThumbnailUri, SessionThumbnailDisplayUrl = "ms-appx:///Assets/SessionPlaceholder.jpg", IsActualSession = g.ToList()[0].IsActualSession, IsNextSession = g.ToList()[0].IsNextSession, DownloadItems = g.ToList().Select(item => new { Caption = item.Caption, Description = item.Description, Url = item.Url }).ToList(), }).ToList(); actualSession = sessionGroupedApi.Select(item => new Session() { SessionDate = item.SessionDate.ToString(), SessionDescription = item.SessionDescription, SessionSubTitle = item.SessionSubTitle, SessionThumbnailDisplayUrl = item.SessionThumbnailDisplayUrl, SessionThumbnailUrl = item.SessionThumbnailUrl, SessionTitle = item.SessionTitle, SessionVideoUrl = item.SessionVideoUri, Speaker = item.Speaker, SessionDownloadItem = item.DownloadItems.Select(_ => new DownloadItemInfo() { Caption = _.Caption, Description = _.Description, Url = _.Url, }).ToList <DownloadItemInfo>(), }).ToList <Session>(); #endregion - Mobile Service API - return(actualSession); }
private static void Main(string[] args) { Stream inputFile = null; Grammar grammar = null; ErrorHandler handler = new ErrorHandler(); Lexers.Scanner scanner = null; Parser.Parser parser = null; Assembly assm = Assembly.GetExecutingAssembly(); object info = Attribute.GetCustomAttribute(assm, typeof(AssemblyFileVersionAttribute)); versionInfo = ((AssemblyFileVersionAttribute)info).Version; try { string filename = ProcessOptions(args); if (filename == null) { return; } try { inputFile = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); } catch (IOException) { inputFile = null; string message = String.Format(CultureInfo.InvariantCulture, "Source file <{0}> not found{1}", filename, Environment.NewLine); handler.AddError(message, null); // aast.AtStart; throw; } scanner = new Lexers.Scanner(inputFile); scanner.SetHandler(handler); parser = new Parser.Parser(filename, scanner, handler); // // If the parse is successful, then process the grammar. // Otherwise just report the errors that have been listed. // if (parser.Parse()) { grammar = parser.Grammar; if (Terminal.Max > 255) { handler.ListError(null, 103, CharacterUtilities.Map(Terminal.Max), '\''); } LALRGenerator generator = new LALRGenerator(grammar); List <AutomatonState> states = generator.BuildStates(); generator.ComputeLookAhead(); generator.BuildParseTable(); if (!grammar.CheckGrammar(handler)) { throw new ArgumentException("Non-terminating grammar"); } // // If the grammar has non-terminating non-terms we cannot // create a diagnostic report as the grammar is incomplete. // bool DoDiagnose = Diagnose && !grammar.HasNonTerminatingNonTerms; if (Report || DoDiagnose) { string htmlName = System.IO.Path.ChangeExtension(filename, ".report.html"); try { System.IO.FileStream htmlFile = new System.IO.FileStream(htmlName, System.IO.FileMode.Create); System.IO.StreamWriter htmlWriter = new System.IO.StreamWriter(htmlFile); Grammar.HtmlHeader(htmlWriter, filename); if (Report && DoDiagnose) { grammar.GenerateCompoundReport(htmlWriter, filename, states); } else if (Report) { grammar.GenerateReport(htmlWriter, filename, states); } Grammar.HtmlTrailer(htmlWriter); if (htmlFile != null) { htmlWriter.Flush(); htmlFile.Close(); } } catch (System.IO.IOException) { Console.Error.WriteLine("Cannot create html output file {0}", htmlName); } } else if (!handler.Errors) { CodeGenerator code = new CodeGenerator(); code.Generate(states, grammar); } } } catch (System.Exception e) { Console.Error.WriteLine("Unexpected Error {0}", e.Message); throw; // Now rethrow the caught exception. } finally { if ((handler.Errors || handler.Warnings) && scanner != null) { handler.DumpAll(scanner.Buffer, Console.Error); } if (Listing || handler.Errors || handler.Warnings) { string listName = parser.ListfileName; StreamWriter listStream = ListingFile(listName); if (listStream != null) { handler.MakeListing(scanner.Buffer, listStream, parser.SourceFileName, versionInfo); } } } }
private void CheckMode(char[] data, CodeTracker cdt) { int extra = 0; int extra2 = 0; while (cdt.offset + extra + extra2 < data.Length && IsEscape(data[cdt.offset])) { if (cdt.offset + extra + extra2 + 1 == data.Length) { cdt.offset += 1; if (errorList != null) { errorList.AddError(Error.MINOR_ERROR, "Escape character found at end of field, discarding it."); } else { throw new MarcException("Escape character found at end of field"); } break; } switch (data[cdt.offset + 1 + extra]) { case (char)0x28: // '(' case (char)0x2c: // ',' Set_cdt(cdt, 0, data, 2 + extra, false); break; case (char)0x29: // ')' case (char)0x2d: // '-' Set_cdt(cdt, 1, data, 2 + extra, false); break; case (char)0x24: // '$' if (!loadedMultibyte) { LoadMultibyte(); loadedMultibyte = true; } switch (data[cdt.offset + 2 + extra + extra2]) { case (char)0x29: // ')' case (char)0x2d: // '-' Set_cdt(cdt, 1, data, 3 + extra + extra2, true); break; case (char)0x2c: // ',' Set_cdt(cdt, 0, data, 3 + extra + extra2, true); break; case (char)0x31: // '1' cdt.g0 = data[cdt.offset + 2 + extra + extra2]; cdt.offset += 3 + extra + extra2; cdt.multibyte = true; break; case (char)0x20: // ' ' // space found in escape code: look ahead and try to proceed extra2++; break; default: // unknown code character found: discard escape sequence and return cdt.offset += 1; if (errorList != null) { errorList.AddError(Error.MINOR_ERROR, "Unknown character set code found following escape character. Discarding escape character."); } else { throw new MarcException("Unknown character set code found following escape character."); } break; } break; case (char)0x67: // 'g' case (char)0x62: // 'b' case (char)0x70: // 'p' cdt.g0 = data[cdt.offset + 1 + extra]; cdt.offset += 2 + extra; cdt.multibyte = false; break; case (char)0x73: // 's' cdt.g0 = 0x42; cdt.offset += 2 + extra; cdt.multibyte = false; break; case (char)0x20: // ' ' // space found in escape code: look ahead and try to proceed if (errorList == null) { throw new MarcException("Extraneous space character found within MARC8 character set escape sequence"); } extra++; break; default: // unknown code character found: discard escape sequence and return cdt.offset += 1; if (errorList != null) { errorList.AddError(Error.MINOR_ERROR, "Unknown character set code found following escape character. Discarding escape character."); } else { throw new MarcException("Unknown character set code found following escape character."); } break; } } if (errorList != null && (extra != 0 || extra2 != 0)) { errorList.AddError(Error.ERROR_TYPO, "" + (extra + extra2) + " extraneous space characters found within MARC8 character set escape sequence"); } }
private void CheckAllErrors() { string check_client_file = laucherSettings.GetClientLocation() + @"\" + laucherSettings.GetClientFilename() + ".exe"; if (!File.Exists(check_client_file)) { ErrorHandler.AddError(111, "Cannot find client at this location."); } string check_server_file = laucherSettings.GetServerLocation() + @"\" + laucherSettings.GetServerFilename() + ".exe"; if (!File.Exists(check_server_file)) { ErrorHandler.AddError(112, "Cannot find server at this location."); } DisplayErrors(); }