static void Main(string[] args) { parser p = new parser(); game g = p.parse(args[0]); g.socialPlanner(); }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() { parser parser_obj; // create a parser and parse with it parser_obj = new parser(); try { if (opt_do_debug) { parser_obj.debug_parse(); } else { parser_obj.parse(); } } catch (Exception e) { // something threw an exception. catch it and emit a message so we // have a line number to work with, then re-throw it lexer.emit_error("Internal error: Unexpected exception"); throw e; } }
void Button1Click(object sender, EventArgs e) { try{ string patharch=tabControl1.SelectedTab.Name; StreamReader archivo=new StreamReader(patharch); sc=new Scanner(archivo); parse = new parser(sc); parse.parse(); archivo.Close(); MessageBox.Show("Proceso de CompilaciĆ³n Finalizado."); richTextBox1.Text=sc.errores+parse.errores; generacionCodigo.generadorCodigo generador=new generacionCodigo.generadorCodigo(); Type tipo=generador.iniciarConstruccion(parse.raiz); object ptInstance = Activator.CreateInstance(tipo, new object[0]); tipo.InvokeMember("main", BindingFlags.InvokeMethod, null, ptInstance, new object[0]); button4.Enabled=true; } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }
/*. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .*/ /// <summary>Parse the grammar specification from standard input. This produces /// sets of terminal, non-terminals, and productions which can be accessed /// via static variables of the respective classes, as well as the setting /// of various variables (mostly in the emit class) for small user supplied /// items such as the code to scan with. /// </summary> protected internal static void parse_grammar_spec() { parser parser_obj; /* create a parser and parse with it */ parser_obj = new parser(); try { if (opt_do_debug) { parser_obj.debug_parse(); } else { parser_obj.parse(); } } catch (System.Exception e) { /* something threw an exception. catch it and emit a message so we * have a line number to work with, then re-throw it */ lexer.emit_error("Internal error: Unexpected exception"); Console.WriteLine("Internal Error: {0}", e.ToString()); Console.WriteLine(e.StackTrace); throw e; } }
public static Expression fromString(System.String s) { Expression result; try { parser p = new parser(new scanner(new System.IO.StringReader(s))); result = (Expression)p.parse().value_Renamed; } catch (System.Exception e) { System.Console.Out.WriteLine("parse error"); result = new Variable("error"); } return(result); }
public static Expression fromFileName(System.String s, System.String filename) { System.String content = ""; Expression result; try { //UPGRADE_TODO: Constructor 'java.io.FileInputStream.FileInputStream' was converted to 'System.IO.FileStream.FileStream' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileInputStreamFileInputStream_javalangString'" System.IO.FileStream infile = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read); //UPGRADE_TODO: The differences in the expected value of parameters for constructor 'java.io.BufferedReader.BufferedReader' may cause compilation errors. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1092'" //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'" System.IO.StreamReader filereader = new System.IO.StreamReader(new System.IO.StreamReader(infile, System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(infile, System.Text.Encoding.Default).CurrentEncoding); System.String nextline = ""; while (nextline != null) { content = content + "\n" + nextline; nextline = filereader.ReadLine(); } } catch (System.Exception e) { System.Console.Out.WriteLine("error while reading input"); result = new Variable("error"); } try { parser p = new parser(new scanner(new System.IO.StringReader(s + content))); result = (Expression)p.parse().value_Renamed; } catch (System.Exception e) { System.Console.Out.WriteLine("parse error"); result = new Variable("error"); } return(result); }
async Task <List <BalanceClient> > GenerateTemplateGrid(int Cols) { GLReportTemplate template; var templateCache = api.GetCache(typeof(GLReportTemplate)); if (templateCache != null) { template = (GLReportTemplate)templateCache.Get(AppliedTemplate); } else { template = new GLReportTemplate() { _Name = AppliedTemplate }; await api.Read(template); } if (template == null || template.RowId == 0) { return(null); } var reportline = await api.Query <GLReportLine>(template); var items = new TemplateDataContext(); var TemplateReportlist = items.TemplateReportlist; TemplateReportlist.Capacity = reportline.Length; var newBalance = new List <BalanceClient>(reportline.Length); var SumContext = new TemplateSumContext(Cols); var colCount = PassedCriteria.selectedCriteria.Count; bool AnyHidden = false; int i, j; for (j = 0; (j < reportline.Length); j++) { var line = reportline[j]; var amounts = new long[colCount]; if (line._Accounts != null && !line._ExpressionSum) { var SumAccounts = PropValuePair.GenereteWhereElements("Account", typeof(string), line._Accounts); foreach (var balSum in balanceClient) { if (balSum.AccountTypeEnum > GLAccountTypes.CalculationExpression && AccountSum.IsIncluded(SumAccounts, balSum.AccountNo)) { balSum.SumUpAmount(amounts); } } if (Skip0Account) { bool found = false; for (i = 0; (i < Cols); i++) { if (amounts[i] != 0) { found = true; break; } } if (!found) { continue; } } } if (line._InvertSign) { for (i = 0; (i < Cols); i++) { amounts[i] = -amounts[i]; } } if (line._SaveTotal != 0) { SumContext.CalcMethod.AddSum(line._SaveTotal, amounts); } if (line._Hide) { AnyHidden = true; } var newBalanceCol = new BalanceClient(amounts); newBalanceCol.Acc._Name = line._Text; newBalance.Add(newBalanceCol); TemplateReportlist.Add(new TemplateDataItems(newBalanceCol, hdrData, line) { Masterfontsize = template._FontSize }); } // Now we will take all expressions and update. var pars = new parser(SumContext); for (j = 0; (j < TemplateReportlist.Count); j++) { var item = TemplateReportlist[j]; var line = item.line; if (line._ExpressionSum) { var InvertSign = line._InvertSign; var e = pars.parse(line._Accounts, Uniconta.Script.ValueType.Double); if (e != null) { var amounts = item.blc.amount; for (i = 0; (i < Cols); i++) { SumContext.CurIndex = i; var val = NumberConvert.ToLong(e.Value()); amounts[i] = !InvertSign ? val : -val; } if (line._SaveTotal != 0) { SumContext.CalcMethod.AddSum(line._SaveTotal, amounts); } } } } if (AnyHidden) { for (i = TemplateReportlist.Count; (--i >= 0);) { if (TemplateReportlist[i].line._Hide) { TemplateReportlist.RemoveAt(i); } } } AccountName.Visible = AccountNo.Visible = false; Text.Visible = true; dgBalanceReport.ItemsSource = TemplateReportlist; templateReportData = new object[] { items, hdrData, PassedCriteria.ObjBalance, null }; return(newBalance); }