Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:22:38+00:00 2026-05-31T04:22:38+00:00

I’m trying to debug my c# application that check MIPS syntax. But its not

  • 0

I’m trying to debug my c# application that check MIPS syntax. But its not allowing be to debug it. No matter where I enter my break point it gets ignored, including the first line of the Main() function. Its also throwing me this error.
‘add a b c’ works fine if i don’t call HasValidParams()
‘add a b’ throws exception in the same situation
neither works when calling HasValidParams()

enter image description here

program.cs

private static void Main(string[] args)
        {
            var validator = new MipsValidator();
            Console.Write("Please enter a MIPS statement: ");
            string input = Console.ReadLine();
            List<string> arguments = input.Split(new char[0]).ToList();
            Response status = validator.IsSyntaxValid(arguments);
            //Check syntax
            if (status.Success.Equals(true))
            {
                Response stat = validator.HasValidParams(arguments);
                //Check parameters
                if (stat.Success.Equals(true))
                {
                Console.WriteLine(string.Format("'{0}' is a valid mips instruction ", input));
                }
                else
                {
                    foreach (var reason in stat.Reasons)
                    {
                        Console.WriteLine(reason);
                    }
                }
            }
            else
            {
                foreach (string reason in status.Reasons)
                {
                    Console.WriteLine(reason);
                }
            }
        }

mips-validator.cs

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace mips_validator.utils
{
    public class MipsValidator : IMipsValidator
    {
        #region Implementation of IMipsValidator

        public Response IsSyntaxValid(List<string> args)
        {
            var response = new Response {Success = true};
            var op = (Operator) Enum.Parse(typeof (Operator), args[0]);
            switch (op)
            {
                case Operator.addi:
                case Operator.add:
                case Operator.beq:
                    if (args.Count != 4)
                    {
                        response.Reasons.Add(string.Format("4 operands required for {0}, {1} parameters provided.",
                                                           op, args.Count));
                        response.Success = false;
                    }
                    break;
                case Operator.j:
                    if (args.Count != 2)
                    {
                        response.Reasons.Add(string.Format("1 operands required for {1}, {0} parameters provided.",
                                                           args.Count, op));
                        response.Success = false;
                    }
                    break;
                default:
                    response.Reasons.Add(string.Format("{0} is an unknown mips operation", op));
                    response.Success = false;
                    break;
            }
            return response;
        }

        public Response HasValidParams(List<string> parameters)
        {
            string op1, op2, op3;
            var temporary = new Regex(@"/\$t\d+/");
            var store = new Regex(@"/\$s\d+/");
            var zero = new Regex(@"/\$zero/");
            var osReserved = new Regex(@"/\$k0|1/");
            var memory = new Regex(@"");
            var constant = new Regex(@"/-?\d*/");
            var label = new Regex(@"/.*\:/");
            Operator operation;
            var response = new Response {Success = true};
            string opString = parameters[0];
            Enum.TryParse(opString.Replace("$", string.Empty), true, out operation);
            switch (operation)
            {
                case Operator.add:
                    {
                        op1 = parameters[1];
                        op2 = parameters[2];
                        if (!temporary.IsMatch(op1) && !store.IsMatch(op1) && !zero.IsMatch(op1))
                        {
                            response.Reasons.Add(string.Format("{0}: error register expected", op1));
                            response.Success = false;
                        }
                        if (!temporary.IsMatch(op2) && !store.IsMatch(op2) && !zero.IsMatch(op2))
                        {
                            response.Reasons.Add(string.Format("{0}: error register expected", op2));
                            response.Success = false;
                        }
                    }
                    break;
                case Operator.addi:
                    {
                        op1 = parameters[1];
                        op2 = parameters[2];
                        if (!temporary.IsMatch(op1) && !store.IsMatch(op1) && !zero.IsMatch(op1))
                        {
                            response.Reasons.Add(string.Format("{0}: error register expected", op1));
                            response.Success = false;
                        }
                        if (!constant.IsMatch(op2) && !zero.IsMatch(op2))
                        {
                            response.Reasons.Add(string.Format("{0}: error constant expected", op2));
                            response.Success = false;
                        }
                    }
                    break;
                case Operator.beq:
                    {
                        op1 = parameters[1];
                        op2 = parameters[2];
                        op3 = parameters[3];
                        if (!temporary.IsMatch(op1) && !store.IsMatch(op1) && !zero.IsMatch(op1))
                        {
                            response.Reasons.Add(string.Format("{0}:  error register expected", op1));
                            response.Success = false;
                        }
                        if (!temporary.IsMatch(op2) && !store.IsMatch(op2) && !zero.IsMatch(op2))
                        {
                            response.Reasons.Add(string.Format("{0}: error register expected", op2));
                            response.Success = false;
                        }
                        if (!label.IsMatch(op3) && !constant.IsMatch(op3))
                        {
                            response.Reasons.Add(string.Format("{0}: error label or constant expected", op3));
                            response.Success = false;
                        }
                    }
                    break;
            }

            return response;
        }

        #endregion
    }
}

SOLUTION——-
Response.cs(old)

public class Response
{
    public List<string> Reasons;
    public bool Success = true;

}

Response.cs(current)

 public class Response
    {
        public Response()
        {
            Reasons = new List<string>();
            Success = true;
        }
        public List<string> Reasons;
        public bool Success = true;

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:22:40+00:00Added an answer on May 31, 2026 at 4:22 am

    I can’t tell if you’re looking for a way to be able to debug your project or if you’d prefer to be told potential issues in your code.

    For the latter:

    Make sure Response.Reasons is initialized by the constructor of Response (or a field initializer).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.