void Awake() { Terminal.Add(new TerminalCommand { Label = "Clear", Method = () => Terminal.Clear() }); }
protected void Awake() { Terminal.Add(new TerminalCommand { Label = "Spam", Method = () => StartCoroutine(DoSpam()) }); }
void Awake() { Terminal.Add(new TerminalCommand { Label = "About", Method = () => Terminal.Log(Text) }); }
private void Awake() { Terminal.Add( new TerminalCommand { Label = "SystemInfo", Method = () => DoSystemInfo() }); }
private void Awake() { Terminal.Add( new TerminalCommand { Label = "Save", Method = () => DoSave() }); }
void Awake() { #if UNITY_STANDALONE Terminal.Add(new TerminalCommand { Label = "Full Screen", Method = () => { Screen.fullScreen = !Screen.fullScreen; } }); #endif }
void LoadCommands() { Terminal.Add(new TerminalCommand { Label = "TestAuthentication", Method = () => StartCoroutine(TestAuthenticationAsync()) }); Terminal.Add(new TerminalCommand { Label = "Authenticate", Method = () => StartCoroutine(AuthenticateAsync()) }); Terminal.Add(new TerminalCommand { Label = "TestRest", Method = () => StartCoroutine(TestRestAsync()) }); Terminal.Add(new TerminalCommand { Label = "TestQuery", Method = () => StartCoroutine(TestQueryAsync()) }); Terminal.Add(new TerminalCommand { Label = "TestLists", Method = () => StartCoroutine(TestListsAsync()) }); // Terminal.Add(new TerminalCommand { Label = "TestTables", Method = () => StartCoroutine(TestRestTableAsync()) }); Terminal.Add(new TerminalCommand { Label = "TestTableRef", Method = () => StartCoroutine(TestTableRefAsync()) }); Terminal.Add(new TerminalCommand { Label = "TestItemRef", Method = () => StartCoroutine(TestItemRefAsync()) }); }
public int?AddTerminal(TerminalEntity objTerminal) { if (WebOperationContext.Current.IncomingRequest.Method == "OPTIONS") { return(null); } else { try { return(Terminal.Add(objTerminal)); } catch (Exception ex) { throw new WebFaultException <string>(ex.Message, HttpStatusCode.ExpectationFailed); } } }
void Awake() { #if UNITY_EDITOR Terminal.Add(new TerminalCommand { Label = "Quit", Method = () => { UnityEditor.EditorApplication.isPlaying = false; } }); #elif UNITY_STANDALONE || UNITY_ANDROID Terminal.Add(new TerminalCommand { Label = "Quit", Method = () => Application.Quit() }); #endif }
private void button1_Click(object sender, EventArgs e) { initGrammar(); textBox3.Text = ""; textBox5.Text = ""; int t = 0; foreach (string strLine in richTextBox1.Lines) { int llen = strLine.Length; string nextLine = ""; for (int i = 0; i < llen; i++) { if (strLine[i] != ' ') { nextLine += strLine[i].ToString(); } } int pos = nextLine.IndexOf("->"); string str = nextLine.Substring(0, pos); int val = 0; if (!nonTerminal.TryGetValue(str, out val)) { nonTerminal.Add(str, nonCount); notTerminal[nonCount] = str; line[nonCount, 0] = 1; line[nonCount, 1] = t; nonCount++; } else { int cur = nonTerminal[str]; line[cur, 0]++; line[cur, line[cur, 0]] = t; } t++; /*pos += 2; * for (int i = 0; i < 7; i++) * { * //int pos = nextLine.IndexOf(terminal[i],pos); * if (nextLine.IndexOf(terminal[i], pos) >= 0) * isTermial[i] = true; * }*/ } //textBox3.Text += "io"; for (int i = 0; i < nonCount; i++) { father[i] = i; } foreach (string strLine in richTextBox1.Lines) { int llen = strLine.Length; string nextLine = ""; for (int i = 0; i < llen; i++) { if (strLine[i] != ' ') { nextLine += strLine[i].ToString(); } } int pos = nextLine.IndexOf("->"); int cur = pos + 2; pos += 2; int len = nextLine.Length; int id = nonTerminal[nextLine.Substring(0, pos - 2)]; //int id = 0; //textBox3.Text += nonCount; while (pos < len) { int val; if (!nonTerminal.TryGetValue(nextLine[pos].ToString(), out val) && nextLine[pos] != '|' && nextLine[pos] != ' ' && !Terminal.TryGetValue(nextLine[pos].ToString(), out val)) { terminal[terminatalCount] = nextLine[pos].ToString(); Terminal.Add(nextLine[pos].ToString(), terminatalCount); terminatalCount++; } else if (nonTerminal.TryGetValue(nextLine[pos].ToString(), out val)) { istarget[nonTerminal[nextLine[pos].ToString()]] = true; if (pos == len - 1 && nextLine[pos - 1] == '|') { son[nonTerminal[nextLine[pos].ToString()]] = true; father[nonTerminal[nextLine[pos].ToString()]] = id; } else if (pos == len - 1 && pos == cur) { son[nonTerminal[nextLine[pos].ToString()]] = true; father[nonTerminal[nextLine[pos].ToString()]] = id; } else if (pos == cur && nextLine[pos + 1] == '|') { son[nonTerminal[nextLine[pos].ToString()]] = true; father[nonTerminal[nextLine[pos].ToString()]] = id; } else if (nextLine[pos - 1] == '|' && nextLine[pos + 1] == '|') { son[nonTerminal[nextLine[pos].ToString()]] = true; father[nonTerminal[nextLine[pos].ToString()]] = id; } } pos++; } } for (int i = 0; i < nonCount; i++) { if (father[i] != i) { Find(i); } } //textBox3.Text = "po"; foreach (string strLine in richTextBox1.Lines) { int llen = strLine.Length; string nextLine = ""; for (int i = 0; i < llen; i++) { if (strLine[i] != ' ') { nextLine += strLine[i].ToString(); } } int pos = nextLine.IndexOf("->"); string str = nextLine.Substring(0, pos); /*int val = 0; * if(!nonTerminal.TryGetValue(str, out val)) * { * nonTerminal.Add(str, nonCount); * }*/ pos += 2; int id = nonTerminal[str]; int len = nextLine.Length; int l = pos; while (l < len) { int tmp = nextLine.IndexOf("|", pos); if (tmp == -1) { l = len; } else { l = tmp; } int nn = 0; if (l - pos == 1 && Terminal.TryGetValue(nextLine[pos].ToString(), out nn)) { isConversion[Terminal[nextLine[pos].ToString()], conversionNum[Terminal[nextLine[pos].ToString()]]].l = -1; isConversion[Terminal[nextLine[pos].ToString()], conversionNum[Terminal[nextLine[pos].ToString()]]].r = -1; isConversion[Terminal[nextLine[pos].ToString()], conversionNum[Terminal[nextLine[pos].ToString()]]].res = id; conversionNum[Terminal[nextLine[pos].ToString()]]++; } else if (l - pos == 3 && nonTerminal.TryGetValue(nextLine[pos].ToString(), out nn) && nonTerminal.TryGetValue(nextLine[pos + 2].ToString(), out nn) && Terminal.TryGetValue(nextLine[pos + 1].ToString(), out nn)) { int temp = Terminal[nextLine[pos + 1].ToString()]; isConversion[temp, conversionNum[temp]].l = father[nonTerminal[nextLine[pos].ToString()]]; isConversion[temp, conversionNum[temp]].r = father[nonTerminal[nextLine[pos + 2].ToString()]]; isConversion[temp, conversionNum[temp]].res = id; conversionNum[temp]++; } else if (l - pos == 3 && Terminal.TryGetValue(nextLine[pos].ToString(), out nn) && Terminal.TryGetValue(nextLine[pos + 2].ToString(), out nn) && nonTerminal.TryGetValue(nextLine[pos + 1].ToString(), out nn)) { int temp = Terminal[nextLine[pos].ToString()]; isConversion[temp, conversionNum[temp]].l = -1; isConversion[temp, conversionNum[temp]].r = father[nonTerminal[nextLine[pos + 1].ToString()]]; isConversion[temp, conversionNum[temp]].res = id; conversionNum[temp]++; } else if (l - pos == 2) { if (Terminal.TryGetValue(nextLine[pos].ToString(), out nn) && nonTerminal.TryGetValue(nextLine[pos + 1].ToString(), out nn)) { int temp = Terminal[nextLine[pos].ToString()]; isConversion[temp, conversionNum[temp]].l = -2; isConversion[temp, conversionNum[temp]].r = father[nonTerminal[nextLine[pos + 1].ToString()]]; isConversion[temp, conversionNum[temp]].res = id; conversionNum[temp]++; } else if (Terminal.TryGetValue(nextLine[pos + 1].ToString(), out nn) && nonTerminal.TryGetValue(nextLine[pos].ToString(), out nn)) { int temp = Terminal[nextLine[pos + 1].ToString()]; isConversion[temp, conversionNum[temp]].r = -2; isConversion[temp, conversionNum[temp]].l = father[nonTerminal[nextLine[pos].ToString()]]; isConversion[temp, conversionNum[temp]].res = id; conversionNum[temp]++; } } bool isStart = true; while (pos < l) { int temp = pos; int cnt = -1; for (int i = 0; i < terminatalCount; i++) { int cur = nextLine.IndexOf(terminal[i], pos, l - pos); if (cur > -1) { if (cnt == -1 || cur < cnt) { cnt = cur; } } } if (cnt == -1) { string ss = nextLine.Substring(pos, l - pos); int val = 0; if (nonTerminal.TryGetValue(ss, out val)) { isSuff[nonTerminal[ss], id] = true; if (ok(nextLine[pos - 1])) { last[id, Terminal[nextLine[pos - 1].ToString()]] = true; stL.Push(new node(id, Terminal[nextLine[pos - 1].ToString()])); } else { isPre[nonTerminal[ss], id] = true; } /*last[id, Terminal[nextLine[pos].ToString()]] = true; * * stL.Push(new node(id, Terminal[nextLine[pos].ToString()]));*/ } else { textBox3.Text = "这个文法不是算符优先文法 "; textBox3.Text += ss; textBox3.Text += "处非终结符连续"; return; } pos = l; } else { string ss = nextLine.Substring(pos, cnt - pos); if (cnt > pos) { int val = 0; if (nonTerminal.TryGetValue(ss, out val)) { if (isStart) { isPre[nonTerminal[ss], id] = true; } } else { textBox3.Text = "这个文法不是算符优先文法 "; textBox3.Text += ss; textBox3.Text += "处非终结符连续"; return; } } if (isStart) { first[id, Terminal[nextLine[cnt].ToString()]] = true; stF.Push(new node(id, Terminal[nextLine[cnt].ToString()])); } isStart = false; pos = cnt + 1; if (cnt == l - 1) { last[id, Terminal[nextLine[cnt].ToString()]] = true; stL.Push(new node(id, Terminal[nextLine[cnt].ToString()])); } } //pos = cnt; } pos = l + 1; } } //textBox3.Text = "ert"; while (stF.Count > 0) { node tt = (node)stF.Peek(); stF.Pop(); int ll = tt.l, rr = tt.r; for (int i = 0; i < nonCount; i++) { if (isPre[ll, i] && !first[i, rr]) { first[i, rr] = true; stF.Push(new node(i, rr)); } } } while (stL.Count > 0) { node tt = (node)stL.Peek(); stL.Pop(); int ll = tt.l, rr = tt.r; for (int i = 0; i < nonCount; i++) { if (isSuff[ll, i] && !last[i, rr]) { last[i, rr] = true; stL.Push(new node(i, rr)); } } } foreach (string strLine in richTextBox1.Lines) { int llen = strLine.Length; string nextLine = ""; for (int i = 0; i < llen; i++) { if (strLine[i] != ' ') { nextLine += strLine[i].ToString(); } } int pos = nextLine.IndexOf("->"); pos += 2; int len = nextLine.Length; int l = pos; while (l < len) { int tmp = nextLine.IndexOf("|", pos); if (tmp == -1) { l = len; } else { l = tmp; } for (int i = pos; i < l - 1; i++) { if (ok(nextLine[i]) && ok(nextLine[i + 1])) { int ll = Terminal[nextLine[i].ToString()], rr = Terminal[nextLine[i + 1].ToString()]; if (com[ll, rr] > 1) { textBox3.Text = "这不是算法优先文法 "; textBox3.Text += nextLine[i].ToString(); textBox3.Text += "和"; textBox3.Text += nextLine[i + 1].ToString(); textBox3.Text += " 有多于一个关系"; return; } else { com[ll, rr] = 1; } } else if (ok(nextLine[i]) && !ok(nextLine[i + 1])) { if (i < l - 2 && ok(nextLine[i + 2])) { int ll = Terminal[nextLine[i].ToString()], rr = Terminal[nextLine[i + 2].ToString()]; if (com[ll, rr] > 1) { textBox3.Text = "这不是算法优先文法 "; textBox3.Text += nextLine[i].ToString(); textBox3.Text += "和"; textBox3.Text += nextLine[i + 2].ToString(); textBox3.Text += " 有多于一个关系"; return; } else { com[ll, rr] = 1; } } int cnt = nonTerminal[nextLine[i + 1].ToString()]; int seg = Terminal[nextLine[i].ToString()]; for (int j = 0; j < terminatalCount; j++) { if (first[cnt, j]) { if (com[seg, j] > 0 && com[seg, j] != 2) { textBox3.Text = "这不是算法优先文法 "; textBox3.Text += nextLine[i].ToString(); textBox3.Text += "和"; textBox3.Text += terminal[j]; textBox3.Text += " 有多于一个关系"; return; } else { com[seg, j] = 2; } } } } else if (!ok(nextLine[i]) && ok(nextLine[i + 1])) { int ll = nonTerminal[nextLine[i].ToString()]; int rr = Terminal[nextLine[i + 1].ToString()]; for (int j = 0; j < terminatalCount; j++) { if (last[ll, j]) { if (com[j, rr] < 3 && com[j, rr] > 0) { textBox3.Text = "这不是算法优先文法 "; textBox3.Text += terminal[j]; textBox3.Text += "和"; textBox3.Text += nextLine[i + 1].ToString(); textBox3.Text += " 有多于一个关系"; return; } else { com[j, rr] = 3; } } } } } pos = l + 1; } } textBox5.Text = ""; textBox5.Text += "UI集:"; textBox5.Text += Environment.NewLine; for (int i = 0; i < terminatalCount; i++) { textBox5.Text += terminal[i]; textBox5.Text += " "; } textBox5.Text += Environment.NewLine; textBox5.Text += Environment.NewLine; textBox5.Text += "产生式"; textBox5.Text += Environment.NewLine; for (int i = 0; i < nonCount; i++) { if (line[i, 0] == 1) { textBox5.Text += richTextBox1.Lines[line[i, 1]]; } else { textBox5.Text += richTextBox1.Lines[line[i, 1]]; for (int j = 2; j <= line[i, 0]; j++) { textBox5.Text += "|"; int cur = richTextBox1.Lines[line[i, j]].IndexOf("->"); textBox5.Text += richTextBox1.Lines[line[i, j]].Substring(cur + 2); } } textBox5.Text += Environment.NewLine; } textBox5.Text += Environment.NewLine; textBox5.Text += "first集:"; textBox5.Text += Environment.NewLine; for (int i = 0; i < nonCount; i++) { textBox5.Text += notTerminal[i]; textBox5.Text += ": "; for (int j = 0; j < terminatalCount; j++) { if (first[i, j]) { textBox5.Text += terminal[j]; textBox5.Text += " "; } } textBox5.Text += Environment.NewLine; } textBox5.Text += Environment.NewLine; textBox5.Text += "last集:"; textBox5.Text += Environment.NewLine; for (int i = 0; i < nonCount; i++) { textBox5.Text += notTerminal[i]; textBox5.Text += ": "; for (int j = 0; j < terminatalCount; j++) { if (last[i, j]) { textBox5.Text += terminal[j]; textBox5.Text += " "; } } textBox5.Text += Environment.NewLine; } textBox5.Text += Environment.NewLine; textBox5.Text += "算符优先关系表:"; textBox5.Text += Environment.NewLine; textBox5.Text += " "; for (int i = 0; i < terminatalCount; i++) { textBox5.Text += terminal[i]; textBox5.Text += " "; } textBox5.Text += Environment.NewLine; for (int i = 0; i < terminatalCount; i++) { textBox5.Text += terminal[i]; textBox5.Text += " "; for (int j = 0; j < terminatalCount; j++) { if (com[i, j] == 0) { textBox5.Text += " "; } else if (com[i, j] == 1) { textBox5.Text += "= "; } else if (com[i, j] == 2) { textBox5.Text += "< "; } else { textBox5.Text += "> "; } } textBox5.Text += Environment.NewLine; } int vall = 0; if (!Terminal.TryGetValue("#", out vall)) { Terminal.Add("#", terminatalCount); terminal[terminatalCount] = "#"; terminatalCount++; for (int i = 0; i < terminatalCount; i++) { com[terminatalCount - 1, i] = 2; } com[terminatalCount - 1, terminatalCount - 1] = 1; for (int i = 0; i < terminatalCount - 1; i++) { com[i, terminatalCount - 1] = 3; } } }
void LoadCommands() { Terminal.Add(new TerminalInterpreter { Label = "Chat", Method = ReadText }); // Terminal.Add(new TerminalCommand { Label = "Connect", Method = () => StartCoroutine(Connect()) }); Terminal.Add(new TerminalCommand { Label = "Disconnect", Method = () => StartCoroutine(Disconnect()) }); // Terminal.Add(new TerminalCommand { Label = "Subscribe", Method = () => StartCoroutine(Subscribe()) }); Terminal.Add(new TerminalCommand { Label = "Unsubscribe", Method = () => StartCoroutine(Unsubscribe()) }); Terminal.Add(new TerminalCommand { Label = "Send", Method = () => StartCoroutine(Send()) }); // Terminal.Add(new TerminalCommand { Label = "Pause", Method = () => StartCoroutine(Pause()) }); Terminal.Add(new TerminalCommand { Label = "Resume", Method = () => StartCoroutine(Resume()) }); // Terminal.Add(new TerminalCommand { Label = "Auth", Method = () => StartCoroutine(Auth()) }); // Terminal.Add(new TerminalCommand { Label = "EnablePresence", Method = () => StartCoroutine(EnablePresence()) }); Terminal.Add(new TerminalCommand { Label = "DisablePresense", Method = () => StartCoroutine(DisablePresence()) }); Terminal.Add(new TerminalCommand { Label = "Presence", Method = () => StartCoroutine(RequestPresence()) }); // }