コード例 #1
0
        public CommentMode(NestedCommentSyntax exit, IScanning scanning)
        {
            this.scanning = scanning;
            this.exit = exit;
            this.comment = new StringBuilder();

            BeginComment();
        }
コード例 #2
0
        public CommentMode(NestedCommentSyntax exit, IScanning scanning)
        {
            this.scanning = scanning;
            this.exit     = exit;
            this.comment  = new StringBuilder();

            BeginComment();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: bkushnir/IronTextLibrary
        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);
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #5
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
            }
        }
コード例 #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
            }
        }