private bool TryParseSignature(string txtSignature, out Core.Serialization.Procedure_v1 sProc) { // save the user a keystroke. txtSignature = txtSignature + ";"; var lexer = new Core.CLanguage.CLexer(new StringReader(txtSignature)); var cstate = new Core.CLanguage.ParserState(); var cParser = new CParser(cstate, lexer); try { var decl = cParser.Parse_Decl(); sProc = null; if (decl == null) { return(false); } var syms = new SymbolTable(); syms.AddDeclaration(decl); if (syms.Procedures.Count != 1) { return(false); } sProc = (Core.Serialization.Procedure_v1)syms.Procedures[0]; return(true); } catch { sProc = null; return(false); } }
private bool TryParseSignature(string txtSignature, out Core.Serialization.Procedure_v1 sProc) { // save the user a keystroke. txtSignature = txtSignature + ";"; var lexer = new Core.CLanguage.CLexer(new StringReader(txtSignature)); var cstate = new Core.CLanguage.ParserState(); var cParser = new CParser(cstate, lexer); try { var decl = cParser.Parse_Decl(); sProc = null; if (decl == null) return false; var syms = new SymbolTable(); syms.AddDeclaration(decl); if (syms.Procedures.Count != 1) return false; sProc = (Core.Serialization.Procedure_v1) syms.Procedures[0]; return true; } catch { sProc = null; return false; } }
private void ProcedureDeclaration_TextChanged(object sender, EventArgs e) { // save the user a keystroke. var procdeclaration = codeView.ProcedureDeclaration.Text + ";"; var lexer = new Core.CLanguage.CLexer(new StringReader(procdeclaration)); var cstate = new Core.CLanguage.ParserState(); var cParser = new Core.CLanguage.CParser(cstate, lexer); try { var decl = cParser.Parse_Decl(); codeView.ProcedureDeclaration.ForeColor = SystemColors.ControlText; } catch { // If parser failed, show error; codeView.ProcedureDeclaration.ForeColor = Color.Red; } }