internal InputQueue PrintSyntaxTree(StreamWriter writer, InputQueue queue, int value) { string toAppend = ""; for (int i = 0; i < value; i++) { toAppend += "\t"; } if (Derivations.Count != 0 || Type.Equals(Classes.Epsilon)) { writer.WriteLine(toAppend + Type); } else { writer.WriteLine(toAppend + Type + ": " + queue.Pop()); } foreach (ClassNode child in Derivations) { queue = child.PrintSyntaxTree(writer, queue, value + 1); } return(queue); }
private InputQueue(InputQueue oldQueue) { this.pointer = oldQueue.Pointer; this.queue = new List <string>(); foreach (String value in oldQueue.queue) { this.queue.Add(value); } }
internal void PrintSyntaxTree(string path, InputQueue queue) { StreamWriter writer = new StreamWriter(path); InputQueue newQueue = (InputQueue)queue.Clone(); newQueue.Pointer = 0; PrintSyntaxTree(writer, newQueue, 0); writer.Close(); }
/* * This simple method is the starting point of Ogma's parsing process, building the lexicon (lex) and * making a call to the first rule of the CFG. */ public override StructureCollection ParserMethod(String path, ref String name, Tuple <String, Object>[] args) { StructureCollection modelAux = new StructureCollection(); LoadFile(path); Tuple <ClassNode, InputQueue> result = analyser.BuildLexicon(entry); ClassNode lex = result.Item1; entry = result.Item2; entry.Pointer = 0; OGMA(lex); modelAux.listGeneralStructure.Add(model); //return new List<GeneralUseStructure>() { (GeneralUseStructure)model }; return(modelAux); }
private void LoadFile(string path) { TextReader reader = new StreamReader(path); entry = new InputQueue(reader.ReadToEnd()); }