Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 3
0
 public IncludeDirective(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DirectiveContext context) :
     base(context)
 {
     if (context.STRING() != null)
     {
         visitorContext.AddString(context.STRING());
     }
     Filename = context.GetChild(1).NormalizeString();
 }
Esempio n. 4
0
        public LineDirective(IZ80AsmVisitorContext visitorContext, Z80AsmParser.DirectiveContext context) :
            base(context)
        {
            if (context.expr() != null)
            {
                Expr = visitorContext.GetExpression(context.expr());
            }

            if (context.STRING() != null)
            {
                visitorContext.AddString(context.STRING());
            }
            Filename = context.STRING().NormalizeString();
        }
Esempio n. 5
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));
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="Z80AsmParser.directive"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitDirective([NotNull] Z80AsmParser.DirectiveContext context)
 {
     return(VisitChildren(context));
 }
Esempio n. 7
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="Z80AsmParser.directive"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitDirective([NotNull] Z80AsmParser.DirectiveContext context)
 {
 }