예제 #1
0
        /// <summary>
        /// Visit a parse tree produced by <see cref="Generated.Z80AsmParser.directive"/>.
        /// </summary>
        /// <param name="context">The parse tree.</param>
        /// <return>The visitor result.</return>
        public override object VisitDirective(Z80AsmParser.DirectiveContext context)
        {
            if (IsInvalidContext(context))
            {
                return(null);
            }

            _keywordSpan = new TextSpan(context.Start.StartIndex, context.Start.StopIndex + 1);
            var mnemonic = context.GetChild(0).NormalizeToken();

            if (mnemonic == "#INCLUDE")
            {
                return(AddLine(new IncludeDirective
                {
                    Mnemonic = mnemonic,
                    Filename = context.GetChild(1).NormalizeString()
                }, context));
            }
            return(AddLine(new Directive
            {
                Mnemonic = mnemonic,
                Identifier = context.ChildCount > 1
                    ? context.GetChild(1).NormalizeToken()
                    : null,
                Expr = context.GetChild(1) is Z80AsmParser.ExprContext
                    ? (ExpressionNode)VisitExpr(context.GetChild(1) as Z80AsmParser.ExprContext)
                    : null
            }, context));
        }
예제 #2
0
        public override object VisitDirective(Z80AsmParser.DirectiveContext context)
        {
            KeywordSpan = new TextSpan(context.Start.StartIndex, context.Start.StopIndex + 1);
            var mnemonic = context.GetChild(0).NormalizeToken();

            return(mnemonic == "#INCLUDE"
                ? (object)new IncludeDirective(this, context)
                : new Directive(this, context));
        }
예제 #3
0
 public IncludeDirective(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DirectiveContext context) :
     base(context)
 {
     if (context.STRING() != null)
     {
         visitorContext.AddString(context.STRING());
     }
     Filename = context.GetChild(1).NormalizeString();
 }
예제 #4
0
        public override object VisitDirective(Z80AsmParser.DirectiveContext context)
        {
            KeywordSpan = new TextSpan(context.Start.StartIndex, context.Start.StopIndex + 1);
            var mnemonic = context.GetChild(0).NormalizeToken();

            if (context.STRING() != null)
            {
                AddString(context.STRING());
            }
            else if (context.FSTRING() != null)
            {
                AddString(context.FSTRING());
            }
            if (mnemonic == "#INCLUDE")
            {
                return(new IncludeDirective(this, context));
            }
            else if (mnemonic == "#LINE")
            {
                return(new LineDirective(this, context));
            }
            return(new Directive(this, context));
        }