示例#1
0
        /// <summary>
        /// Enter a parse tree produced by <see cref="BBSCodeParser.bbsCodeAttribute"/>.
        /// </summary>
        /// <param name="context">The parse tree.</param>
        public override void EnterBbsCodeAttribute([NotNull] BBSCodeParser.BbsCodeAttributeContext context)
        {
            string tagName        = context.Parent.GetChild(1).GetText().Trim().ToUpper();
            string attributeName  = context.children[0].GetText().Trim().ToUpper();
            string attributeValue = string.Empty;

            if (context.ChildCount > 2)
            {
                attributeValue = context.children[2].GetText().Trim('"').Trim();
            }

            Tags tag;

            if (TagsTable.TryGetValue(tagName, out tag))
            {
                switch (tag)
                {
                case Tags.COLOR:
                    ANSI.pushForeColor(attributeValue);
                    Parsed.TextConcat(ANSI.WriteMode());
                    break;

                case Tags.BACKCOLOR:
                    ANSI.pushBackColor(attributeValue);
                    Parsed.TextConcat(ANSI.WriteMode());
                    break;

                default:
                    AttributesTable.Add(tag, attributeName, attributeValue);
                    break;
                }
            }
        }
示例#2
0
 /// <summary>
 /// Enter a parse tree produced by <see cref="BBSCodeParser.bbsCodeAttribute"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void EnterBbsCodeAttribute([NotNull] BBSCodeParser.BbsCodeAttributeContext context)
 {
 }