public CommentMode(NestedCommentSyntax exit, IScanning scanning) { this.scanning = scanning; this.exit = exit; this.comment = new StringBuilder(); BeginComment(); }
public static void Main(string[] args) { var context = new NestedCommentSyntax(); using (var interp = new Interpreter<NestedCommentSyntax>(context)) { interp.LoggingKind = LoggingKind.Console; const string text = "/*/* /* foo *//* middle */ * / * */ bar */"; bool success = interp.Parse(text); if (success) { Console.WriteLine("Comment text is:"); Console.WriteLine(context.Result); } } }
public static void Main(string[] args) { var context = new NestedCommentSyntax(); using (var interp = new Interpreter <NestedCommentSyntax>(context)) { interp.LoggingKind = LoggingKind.Console; const string text = "/*/* /* foo *//* middle */ * / * */ bar */"; bool success = interp.Parse(text); if (success) { Console.WriteLine("Comment text is:"); Console.WriteLine(context.Result); } } }
public string EndComment(out NestedCommentSyntax mode) { comment.Append("*/"); --nestLevel; Console.WriteLine("decreased comment nest level to {0}", nestLevel); if (nestLevel == 0) { mode = exit; return comment.ToString(); } else { mode = null; // null mode means don't change current mode. scanning.Skip(); // scanner should skip current token value return null; // Ignored token value } }
public string EndComment(out NestedCommentSyntax mode) { comment.Append("*/"); --nestLevel; Console.WriteLine("decreased comment nest level to {0}", nestLevel); if (nestLevel == 0) { mode = exit; return(comment.ToString()); } else { mode = null; // null mode means don't change current mode. scanning.Skip(); // scanner should skip current token value return(null); // Ignored token value } }