static void Main(string[] args) { //Read file string sampleFileName = "First.txt"; MyFileReader myFileReader = new MyFileReader(sampleFileName); string text = myFileReader.ReadFile(); //Make tokens Token[] tokens = new LexicalAnalysis().ProcessTextAndGenerateTokens(text); tokens.ToList().ForEach(t => Console.WriteLine(t.ToString())); Console.WriteLine("--------------------------------------------------------------------\n\n"); //Parse syntax analysis phase SyntaxAnalysis syntaxAnalysis = new SyntaxAnalysis(tokens); SyntaxAnalysisResult syntaxAnalysisResult = syntaxAnalysis.Parse(); if (!syntaxAnalysisResult.SyntaxParsed) { Console.WriteLine(syntaxAnalysisResult.Exception.Message); } else { Console.WriteLine("Syntax Analysis phase passed"); } Console.Read(); }
public CompareForm(SyntaxAnalysis sa, GPDictionary gpDict, LFDictionary lfDict) { this.sa = sa; this.gpDict = gpDict; this.lfDict = lfDict; InitializeComponent(); }
public ImportGPForm(string fileName, SyntaxAnalysis sa, GPDictionary gpDict) { InitializeComponent(); this.fileName = fileName; this.sa = sa; this.gpDict = gpDict; }
public EditLFDictForm(LFDictionary lfDict, SyntaxAnalysis sa) { InitializeComponent(); this.lfDict = lfDict; this.sa = sa; lbLf.Items.AddRange(lfDict.GetList()); labNum.Text = string.Format("Объем: {0}", lbLf.Items.Count); }
public EditGPDictForm(GPDictionary gpDict, SyntaxAnalysis sa) { InitializeComponent(); this.gpDict = gpDict; this.sa = sa; lbGp.Items.AddRange(gpDict.GetList()); lbGpFreq.Items.AddRange(gpDict.GetFreqList()); labNum.Text = string.Format("Объем: {0}", lbGp.Items.Count); }
public ImportLFForm(string fileName, SyntaxAnalysis sa, LFDictionary lfDict) { this.lfDict = lfDict; this.sa = sa; this.fileName = fileName; InitializeComponent(); int valMax = Enum.GetValues(typeof(LexFunction)).Length; for (int i = 1; i < valMax; i++) { lvLf.Items.Add(((LexFunction)i).ToString()); } }
public ResForm(STNode[] arrRootX, STNode[] arrRootY, double[,] matrCmp, double [,] matrParent, double[,] matr, int[] arrIndex, SyntaxAnalysis sa, double res) { InitializeComponent(); tvSa.Nodes.AddRange(sa.CreateTreeNodes(arrRootX)); tvSa.ExpandAll(); tbRes.Text = res.ToString(); List <STNode> listNodeX = STNode.GetDescendants(arrRootX); List <STNode> listNodeY = STNode.GetDescendants(arrRootY); wbCmp.DocumentText = MatrToHTML(matrCmp, listNodeX, listNodeY, arrIndex); wbPar.DocumentText = MatrToHTML(matrParent, listNodeX, listNodeY, arrIndex); wbMatr.DocumentText = MatrToHTML(matr, listNodeX, listNodeY, arrIndex); }
private bool Build() { try { LexicalAnalysis scanner; ClearAnalysersRichTextBoxes(); string fileName = currentFileName ?? defaultFileName; var writeToFile = new StreamWriter(fileName, false, Encoding.Unicode); writeToFile.Write(textEditor.Text); writeToFile.Close(); using (TextReader input = File.OpenText(fileName)) { scanner = new LexicalAnalysis(input); } FillLexicalAnalysisTab(scanner.Tokens); var parser = new SyntaxAnalysis(scanner.Tokens); FillSyntaxAnalysisTab(parser.Result); var generator = new Generator(parser.Result, Path.GetFileNameWithoutExtension(fileName) + ".exe"); TextRange tr = new TextRange(outputRichTextBlock.Document.ContentStart, outputRichTextBlock.Document.ContentStart); tr.Text = DateTime.Now.ToString("dd/MM/yy HH:mm:ss.fff") + " | >>> " + Path.GetFileNameWithoutExtension(fileName) + ".exe successfully build. \r\n"; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); } catch (Exception ex) { TextRange tr = new TextRange(outputRichTextBlock.Document.ContentStart, outputRichTextBlock.Document.ContentStart); tr.Text = DateTime.Now.ToString("dd/MM/yy HH:mm:ss.fff") + " | " + ex.GetType().Name + " >>> Error: " + ex.Message + "\r\n"; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Red); ClearAndFillDefaultValuesAnalysersRichTextBoxes(); return(false); } return(true); }
void MainForm_Load(object sender, EventArgs e) { sa = new SyntaxAnalysis("dictionary.xml", false, false, 2); }