public AscendentDealer(GrammarDeterministicAutomata afd) { _afd = afd; //Para a geração dos firsts e follows _nonRecursiveDealer = new NonRecursiveDealer(); _finalStatesList = new List <GrammarState>(); _table = new SyntaxTable(); _productions = new List <String>(); //Numera todas as produções NumerateProductions(); //Método que gera a tabela GenerateTable(); }
/// <summary> /// Returns string value of a token by it's type and value. /// </summary> /// <param name="type">Type of token to find string value.</param> /// <param name="value">\"Value\" of token to find string value.</param> /// <returns>Actual token's string value.</returns> private string valueOf(int type, int value) { switch (type) { case 1: return(SyntaxTable.operation(value)); case 2: return(SyntaxTable.keyword(value)); case 3: case 4: case 5: return(ident.identifier(value)); default: return(""); } }
/*-------------------------Start Up-------------------------------*/ public MainWindow() : base(Gtk.WindowType.Toplevel) { Build(); table = SyntaxTable.LoadFromFile("highlight\\csharp.hl"); // StatusID = statusbar.GetContextId("status"); // statusbar.Push(StatusID, "Number of Lines: " + logTextView.Buffer.LineCount) + " | Current Line Number: 1"); if (table == null) { MessageDialog dialog = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Could not load Syntax tables"); dialog.Title = "Error"; if ((ResponseType) dialog.Run() == ResponseType.Close) Environment.Exit(0); } table.SetBuffer(logTextView.Buffer); }
public static SyntaxTable LoadFromFile(String filename) { SyntaxTable table = new SyntaxTable(); try { FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader reader = new StreamReader(fs); String line = reader.ReadLine(); // Read in lines until empty do { if (!String.IsNullOrEmpty(line)) { // Get line to form of a=b line = line.Replace(" ", ""); line = line.Replace("\t", ""); String[] split = line.Split('='); if (split.Length != 2) return null; // Extract the property and value String property = split[0]; String value = split[1]; String lowerprop = property.ToLower(); String lowervalue = value.ToLower(); if (lowerprop == "name") table.Name = value; else { if (!table.TagNameToTag.ContainsKey(lowervalue)) table.AddTag(lowervalue); table.KeyToTag[property] = table.TagNameToTag[lowervalue]; } } line = reader.ReadLine(); } while (!reader.EndOfStream || !String.IsNullOrEmpty(line)); reader.Close(); } catch (Exception) { return null; } return table; }