コード例 #1
0
        public override object VisitInicio([NotNull] StdAssemblerParser.InicioContext context)
        {
            string   etiqueta, start, dir;
            StdToken token;

            etiqueta = string.Empty;
            if (context.etiqueta() != null)
            {
                if (context.children.Count > 4)
                {
                    throw new Exception("Error de sintáxis: Instrucción no válida");
                }
                else
                {
                    etiqueta = Visit(context.etiqueta()) as String;
                    start    = context.START().GetText();
                    dir      = context.VAL().GetText();
                    if (!Regex.IsMatch(dir, @"^[0-9A-F]{4}(H|h)$"))
                    {
                        throw new Exception("Error de sintáxis: ingrese una dirección hexadecimal");
                    }
                    if (start.Contains("missing") || dir.Contains("missing"))
                    {
                        throw new Exception("Error de sintáxis: Instrucción no válida");
                    }
                    count = int.Parse(Regex.Replace(dir, "(H|h)", ""), System.Globalization.NumberStyles.HexNumber);
                }
            }
            else
            {
                if (context.children.Count > 3)
                {
                    throw new Exception("Error de sintáxis: Instrucción no válida");
                }
                else
                {
                    start = context.START().GetText();
                    dir   = context.VAL().GetText();
                    if (!Regex.IsMatch(dir, @"^[0-9A-F]{4}(H|h)$"))
                    {
                        throw new Exception("Error de sintáxis: ingrese una dirección hexadecimal");
                    }
                    if (start.Contains("missing") || dir.Contains("missing"))
                    {
                        throw new Exception("Error de sintáxis: Instrucción no válida");
                    }
                    count = int.Parse(Regex.Replace(dir, @"(H|h)", ""), System.Globalization.NumberStyles.HexNumber);
                }
            }
            token = new StdToken()
            {
                Address       = count,
                IsDirective   = true,
                IsHex         = true,
                Label         = etiqueta,
                Mode          = false,
                OperationCode = "START",
                Value         = dir
            };
            TokenList.Add(token);
            return(token);
        }
コード例 #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="StdAssemblerParser.inicio"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitInicio([NotNull] StdAssemblerParser.InicioContext context)
 {
 }
コード例 #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="StdAssemblerParser.inicio"/>.
 /// <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 VisitInicio([NotNull] StdAssemblerParser.InicioContext context)
 {
     return(VisitChildren(context));
 }