private void preparserAvailable(PreParser preParser) { if (Globals.slide == preParser.room || Globals.conversationDetails.Jid == preParser.room.ToString()) { foreach (var file in preParser.files) receiveFile(file); } }
static void Main(string[] args) { var fileName = args.Length > 0 ? args[0] : @"../../Program.cs"; var preParser = new PreParser(); // preprocessor parser SourceSnapshot src; // parsed source using (var reader = new StreamReader(fileName)) { src = new SourceSnapshot(reader.ReadToEnd()); } var preAst = preParser.Parse(src); var preprocessed = Preprocessor.Run(preAst.Value, new string[0]); // transform AST with preprocessor var parser = new Parser(); // C# parser var parsingResult = parser.Parse(preprocessed.Source); var csAST = parsingResult.Value; Console.WriteLine("Usings: "); foreach (var usingDirective in csAST.UsingDirectives) { var ns = usingDirective as UsingDirective.Namespace; if (ns != null) { Console.WriteLine(ns.name); } var alias = usingDirective as UsingDirective.Alias; if (alias != null) { Console.WriteLine("{0} = {1}", alias.name, alias.alias); } } Console.WriteLine("\nClasses: "); ShowMembers(csAST.Members); }
public IEnumerable <CodeGenerator> DoGeneration() { // generation requires two runs - first we collect the grammar yield return(this); // process the grammar _productions = _grammar.Productions.ToArray(); var generator = new ParserGenerator(_grammar); var table = generator.GenerateParserTable(); // on second run we render the code and insert the actions. WriteLine(PreParser.Replace("{VALUETYPE}", _valueType)); // write the token enum WriteTokenEnum(); // write the parser table code WriteParserTableCode(table); // put in the actions at the end using a second run yield return(this); EndAction(); // (manually close the last action) // write the end of the parser function WriteLine(PostParser); }
public void receivePreParser(PreParser pp) { }
public void receivesubmissions(PreParser parser) { }
private void PreParserAvailable(PreParser parser) { foreach (var submission in parser.submissions) receiveSubmission(submission); }
void IReceiveEvents.receivePreParser(PreParser pp) { PreParserAvailable(this, new PreParserAvailableEventArgs { parser = pp }); }
public void receieveQuizzes(PreParser finishedParser) { var quizzes = new List<QuizInfo>(); finishedParser.quizzes.ForEach(q => quizzes.Add(new QuizInfo(q, finishedParser.quizAnswers.Where( a => a.id == q.Id).ToList()))); QuizzesAvailable(this, new QuizzesAvailableEventArgs{ quizzes = quizzes}); }
public void receieveQuiz(PreParser finishedParser, long id) { }
public static bool TryParse(ITextBuffer textBuffer, out ClassificationParseResult parseResult) { var snapshot = textBuffer.CurrentSnapshot; ClassificationParseResult lastParseResult; if (textBuffer.Properties.TryGetProperty(typeof(ClassificationParseResult), out lastParseResult) && lastParseResult.Snapshot.Version == snapshot.Version) { parseResult = lastParseResult; return(true); } NemerleSource source; if (!textBuffer.Properties.TryGetProperty(typeof(NemerleSource), out source)) { parseResult = null; return(false); } var engine = source.GetEngine(); if (!engine.RequestOnInitEngine()) { parseResult = null; return(false); } var timer = Stopwatch.StartNew(); var code = snapshot.GetText(); var lexer = new HighlightingLexer(engine, code); var preParser = new PreParser(lexer); var tokens = preParser.ParseTopLevel(); var _comments = lexer.GetComments(); var directives = lexer.GetDirectives(); var comments = new Comment[_comments.Length]; for (var i = 0; i < _comments.Length; ++i) { var c = _comments[i]; var type = CommentType.Normal; var pos = 0; var commentParser = c.IsMultiline ? _multiLineCommentParser : _singleLineCommentParser; var match = commentParser.Match(code, c.Position, c.Length); if (match.Success) { if (match.Groups[1].Success) { pos = match.Groups[1].Index; type = CommentType.ToDo; } else if (match.Groups[2].Success) { pos = match.Groups[2].Index; type = CommentType.Bug; } else if (match.Groups[3].Success) { pos = match.Groups[3].Index; type = CommentType.Hack; } } comments[i] = new Comment(c, type, pos); } timer.Stop(); Debug.Print("SyntaxClassifier.TryParse: {0}", timer.Elapsed); parseResult = new ClassificationParseResult(snapshot, tokens.Child, comments, directives); textBuffer.Properties[typeof(ClassificationParseResult)] = parseResult; return(true); }
private byte[] parserToInkCanvas(PreParser parser, RequestInfo info) { ManualResetEvent waitHandler = new ManualResetEvent(false); byte[] result = new byte[0]; var staThread = new Thread(new ParameterizedThreadStart(delegate { try { var canvas = new InkCanvas(); parser.Populate(canvas); var viewBox = new Viewbox(); viewBox.Stretch = Stretch.Uniform; viewBox.Child = canvas; viewBox.Width = info.width; viewBox.Height = info.height; var size = new Size(info.width, info.height); viewBox.Measure(size); viewBox.Arrange(new Rect(size)); viewBox.UpdateLayout(); RenderTargetBitmap targetBitmap = new RenderTargetBitmap(info.width, info.height, 96d, 96d, PixelFormats.Pbgra32); targetBitmap.Render(viewBox); PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(targetBitmap)); using (var stream = new MemoryStream()) { encoder.Save(stream); result = stream.ToArray(); } } catch (Exception e) { Trace.TraceInformation("{0}\n{1}", e.Message, e.StackTrace); } finally { waitHandler.Set(); } })); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(); waitHandler.WaitOne(); return result; }
private void preparserAvailable(PreParser preParser) { foreach (var quiz in preParser.quizzes) { ReceiveQuiz(quiz); } foreach (var answer in preParser.quizAnswers) ReceiveQuizAnswer(answer); }
private string describeParser(PreParser pp) { return "Location:" + pp.location.currentSlide.ToString() + " Ink:" + pp.ink.Count.ToString() + " Images:" + pp.images.Count.ToString() + " Text:" + pp.text.Count.ToString() + " Videos:" + pp.videos.Count.ToString() + " Submissions:" + pp.submissions.Count.ToString() + " Quizzes:" + pp.quizzes.Count.ToString() + " QuizAnswers:" + pp.quizAnswers.Count.ToString(); }
public void receieveQuiz(PreParser finishedParser, long id) { var quiz = finishedParser.quizzes.Where(q => q.Id == id).OrderByDescending(q => q.Created).First(); var quizInfo = new QuizInfo(quiz, finishedParser.quizAnswers.Where(a => a.id == id).ToList()); QuizAvailable(this, new QuizzesAvailableEventArgs{ quizzes = new List<QuizInfo>{quizInfo}}); }
public void receieveAttachments(PreParser finishedParser) { var files = new List<TargettedFile>(); finishedParser.files.ForEach(files.Add); AttachmentsAvailable(this, new AttachmentsAvailableEventArgs{ attachments = files}); }
public void receieveQuizzes(PreParser finishedParser) { }
public void receieveAttachments(PreParser finishedParser) { }
private void ReceivePreParser(PreParser p) { ReceiveStrokes(p.ink); foreach (var t in p.text.Values.ToList()) ReceiveTextbox(t); foreach (var i in p.images.Values.ToList()) ReceiveImage(i); foreach (var s in p.submissions) ReceiveSubmission(s); foreach (var a in p.attendances) ReceivePresence(a); }
public static bool TryParse(ITextBuffer textBuffer, out ClassificationParseResult parseResult) { var snapshot = textBuffer.CurrentSnapshot; ClassificationParseResult lastParseResult; if (textBuffer.Properties.TryGetProperty(typeof(ClassificationParseResult), out lastParseResult) && lastParseResult.Snapshot.Version == snapshot.Version) { parseResult = lastParseResult; return true; } NemerleSource source; if (!textBuffer.Properties.TryGetProperty(typeof(NemerleSource), out source)) { parseResult = null; return false; } var engine = source.GetEngine(); if (!engine.RequestOnInitEngine()) { parseResult = null; return false; } var timer = Stopwatch.StartNew(); var code = snapshot.GetText(); var lexer = new HighlightingLexer(engine, code); var preParser = new PreParser(lexer); var tokens = preParser.ParseTopLevel(); var _comments = lexer.GetComments(); var directives = lexer.GetDirectives(); var comments = new Comment[_comments.Length]; for (var i = 0; i < _comments.Length; ++i) { var c = _comments[i]; var type = CommentType.Normal; var pos = 0; var commentParser = c.IsMultiline ? _multiLineCommentParser : _singleLineCommentParser; var match = commentParser.Match(code, c.Position, c.Length); if (match.Success) { if (match.Groups[1].Success) { pos = match.Groups[1].Index; type = CommentType.ToDo; } else if (match.Groups[2].Success) { pos = match.Groups[2].Index; type = CommentType.Bug; } else if (match.Groups[3].Success) { pos = match.Groups[3].Index; type = CommentType.Hack; } } comments[i] = new Comment(c, type, pos); } timer.Stop(); Debug.Print("SyntaxClassifier.TryParse: {0}", timer.Elapsed); parseResult = new ClassificationParseResult(snapshot, tokens.Child, comments, directives); textBuffer.Properties[typeof(ClassificationParseResult)] = parseResult; return true; }
public void receivesubmissions(PreParser parser) { SubmissionsAvailable(this, new SubmissionsAvailableEventArgs{submissions = parser.submissions}); }