/// <summary> /// Gets token and identifier tables from lexical analyzer. /// </summary> /// <param name="token">Token table.</param> /// <param name="ident">Identifiers table.</param> public SyntaxAnalyzer(TokenTable token, IdentifiersTable ident, LexicalAnalyzer lAnalyzer) { this.token = token; this.ident = ident; this.lAnalyzer = lAnalyzer; count = this.token.tokensCount(); }
public void GenerateIdentifierFormShouldAddNewIdentifierTwice() { // arrange var factory = $"FactoryTest-{Guid.NewGuid().ToString().ToLower().Substring(0, 4)}"; var category = $"CategoryTest-{Guid.NewGuid().ToString().ToLower().Substring(0, 4)}"; // act var generateIdentifierForm = new GenerateIdentifierForm(WebDriver); generateIdentifierForm.EnterIdentifierData(factory, category); generateIdentifierForm.Submit(); WebDriver.WaitForLoading(); generateIdentifierForm.ClearFormData(); generateIdentifierForm.EnterIdentifierData(factory, category); generateIdentifierForm.Submit(); WebDriver.WaitForLoading(); var identifiersTable = new IdentifiersTable(WebDriver); // assert var addedRow = identifiersTable.SearchWholeTableForIdentifierRow(factory, category); Assert.NotNull(addedRow); Assert.Equal(2, addedRow.CurrentValue); }
private async void CompileButton_Click(object sender, RoutedEventArgs e) { var str = EditField.Text; var inp = new StringAsFileBuffer(str); _lexer = new LexAn(); try { _lexer.Scan(inp); } catch (FormatException ex) { MessageBox.Show(ex.Message, "Lexical error"); Log = "Error: " + ex.Message; return; } catch (ArgumentException ex) { MessageBox.Show(ex.Message, "Compilation error"); Log = "Error: " + ex.Message; return; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Inner compiler error"); Log = "Please contact the developer " + ex.ToString(); return; } var result = ""; foreach (var s in _lexer.Output) { result += s + " "; } Log = "Lexical output: " + result; Binding b = new Binding(); b.Source = Identifiers; b.Mode = BindingMode.OneWay; BindingOperations.ClearBinding(IdentifiersTable, DataGrid.ItemsSourceProperty); IdentifiersTable.SetBinding(DataGrid.ItemsSourceProperty, b); Binding bs = new Binding(); bs.Source = Constants; bs.Mode = BindingMode.OneWay; BindingOperations.ClearBinding(ConstTable, DataGrid.ItemsSourceProperty); ConstTable.SetBinding(DataGrid.ItemsSourceProperty, bs); var syntax = new SyntaxAnalyser(_lexer); var loading = new Loading(); loading.Show(); loading.progress.Maximum = _lexer.Output.Count - 1; syntax.LexIndexChanged += (i) => ProgressUpdate(loading, i); await Task.Run(() => syntax.BuildAST()); loading.Close(); Log = syntax.IsValid ? "Valid" : "Invalid"; if (!syntax.IsValid) { Log = syntax.ErrorMessage; } else { var root = treeView.Items[0]; DrawTree((TreeViewItem)root, syntax.Tree.Root); tabs.SelectedIndex = 1; } }