Пример #1
0
 /// <summary>
 /// Exit a parse tree produced by the <c>DirectivaFin</c>
 /// labeled alternative in <see cref="SicAsmParser.end"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitDirectivaFin([NotNull] SicAsmParser.DirectivaFinContext context)
 {
 }
Пример #2
0
        public override string VisitDirectivaFin([NotNull] SicAsmParser.DirectivaFinContext context)
        {
            string label = "----";
            string id;

            if (context.LABEL(0) != null)
            {
                label = "Label = " + context.LABEL(0).GetText() + " START addr = ";
            }

            int addr_value = 0;

            if (context.num_type != null)
            {
                if (context.num_type.Type == SicAsmParser.LABEL)
                {
                    if (context.LABEL().Length == 2)
                    {
                        id = context.LABEL(1).GetText();
                    }
                    else
                    {
                        label = "----";
                        id    = context.LABEL(0).GetText();
                    }

                    // Si la etiqueta existe en la tabla de simbolos, obtiene su dirección.
                    if (_symtab.ContainsKey(id))
                    {
                        addr_value = (int)_symtab[id];
                    }
                    else // si no existe en la tabla de simbolos, la dirección es -1.
                    {
                        addr_value = MAX_ADDR;
                    }
                }
                else
                if (context.num_type.Type == SicAsmParser.INT)
                {
                    id         = context.INT().GetText();
                    addr_value = int.Parse(id);
                }
                else
                {
                    id         = context.HEX().GetText().Remove(context.HEX().GetText().Length - 1);
                    addr_value = int.Parse(id, System.Globalization.NumberStyles.HexNumber);
                }

                _first_inst_addr = addr_value;
            }

            if (addr_value > MAX_ADDR)
            {
                return("Error, dirección fuera de rango, debe ser menor a 0x7FFF");
            }

            /* Si es la primera pasada */
            if (_is_first_pass)
            {
                _lines_pc.Add(_line_count + 1, _program_counter);
                _prog_size = _program_counter - _prog_size;
            }
            else /* Si es la segunda pasada agrega el registro E al programa objeto */
            {
                _lines_opcode.Add(_line_count + 1, "------");
            }

            return(label + addr_value);
        }
Пример #3
0
 /// <summary>
 /// Visit a parse tree produced by the <c>DirectivaFin</c>
 /// labeled alternative in <see cref="SicAsmParser.end"/>.
 /// <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 VisitDirectivaFin([NotNull] SicAsmParser.DirectivaFinContext context)
 {
     return(VisitChildren(context));
 }