public IList <string> ScanTokens(string path) { var scannedTokens = new List <string>(); using (var file = File.OpenRead(path)) { var scanner = new Mcs3RobScanner(file); scanner.Initialize(); scanner.Error += (sender, args) => Error?.Invoke(sender, args); int tok; do { tok = scanner.yylex(); scannedTokens.Add(((Token)tok).ToString()); } while (tok > (int)Token.EOF); } return(scannedTokens); }
public void Parse(Stream stream) { var robScanner = new Mcs3RobScanner(stream); robScanner.Initialize(); robScanner.Error += (sender, args) => Error?.Invoke(sender, args); this.Scanner = robScanner; try { if (!this.Parse()) { OnError(new ErrorEventArgs(new ErrorContext(3, this.Scanner.yylloc))); } } catch (Exception e) { OnError(new ErrorEventArgs(new ErrorContext(4, this.Scanner.yylloc, e))); } }