private RecycleParser OpenParser(string fileName) { var file = File.ReadAllText(fileName); file = regex.Replace(file, "\n"); AntlrInputStream stream = new AntlrInputStream(file); ITokenSource lexer = new RecycleLexer(stream); ITokenStream tokens = new CommonTokenStream(lexer); return(new RecycleParser(tokens)); }
public Tuple <bool, bool> Loader() { Debug.AutoFlush = true; if (exp.logging) { File.WriteAllText(exp.fileName + ".txt", string.Empty); } /************ * Load up the game from the .gdl RECYCLE description ************/ fileName = exp.fileName; Console.WriteLine("name: " + fileName); var file = File.ReadAllText(fileName); var regex = new Regex("(;;)(.*?)(\n)"); file = regex.Replace(file, "\n"); /*********** * Parse the game with the Antlr grammar description ***********/ AntlrInputStream stream = new AntlrInputStream(file); ITokenSource lexer = new RecycleLexer(stream); ITokenStream tokens = new CommonTokenStream(lexer); var parser = new RecycleParser(tokens); parser.BuildParseTree = true; this.tree = parser.game(); /*********** * Make the parse tree visualization ***********/ if (!exp.evaluating) { DotVisualization.DOTMakerTop(tree, exp.fileName); } return(HasShuffleAndChoice(tree)); }