예제 #1
0
 static void SerializeJunk(IndentingWriter writer, Ast.Junk junk)
 {
     if (!String.IsNullOrEmpty(junk.Content))
     {
         writer.Write(junk.Content);
     }
 }
예제 #2
0
        Ast.Entry GetEntryOrJunk(FtlParserStream ps)
        {
            var entryStartPos = ps.GetPosition();

            ps.BeginCapture();

            try
            {
                var entry = GetEntry(ps);
                ps.ExpectNewLine();
                return(entry);
            }
            catch (ParseException e)
            {
                var errorPos = ps.GetPosition();
                ps.SkipToNextEntryStart();
                var nextEntryStart = ps.GetPosition();

                // Create a Junk instance
                var junk = new Ast.Junk(ps.GetCapturedText());
                if (_withSpans)
                {
                    junk.AddSpan(entryStartPos, nextEntryStart);
                }
                var annot = new Ast.Annotation(e.Code, e.Args, e.Message);
                annot.AddSpan(errorPos, errorPos);
                junk.AddAnnotation(annot);
                return(junk);
            }
        }