public CommentMode(NestedCommentSyntax exit, IScanning scanning)
        {
            this.scanning = scanning;
            this.exit = exit;
            this.comment = new StringBuilder();

            BeginComment();
        }
Ejemplo n.º 2
0
        public CommentMode(NestedCommentSyntax exit, IScanning scanning)
        {
            this.scanning = scanning;
            this.exit     = exit;
            this.comment  = new StringBuilder();

            BeginComment();
        }
Ejemplo n.º 3
0
        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);
                }
            }
        }
Ejemplo n.º 4
0
        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
            }
        }
Ejemplo n.º 6
0
        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
            }
        }