public static bool TryParse(string input, out RegisterSyntax registerSyntax, BracketExpectation bracketExpectation = BracketExpectation.NotPresent)
        {
            bool isSuccess;

            bool isRegister = Regex.IsMatch(input, @"^\[?R[0-9A-F]\]?$");

            bool isSurroundedByBrackets = input.StartsWith("[") && input.EndsWith("]");

            if (bracketExpectation == BracketExpectation.Present)
            {
                isSuccess = isRegister && isSurroundedByBrackets;
            }
            else
            {
                isSuccess = isRegister && !isSurroundedByBrackets;
            }

            if (isSuccess)
            {
                registerSyntax = new RegisterSyntax(input.Trim('[', ']'));
            }
            else
            {
                registerSyntax = null;
            }

            return(isSuccess);
        }
Exemple #2
0
            public static bool TryParseAddress(string input, out AddressSyntax addressSyntax, BracketExpectation bracketExpectation = BracketExpectation.NotPresent)
            {
                bool isSuccess;

                byte address;
                string undefinedLabel;
                bool isAddress = IsAddress(input.Trim('[', ']'), out address, out undefinedLabel);

                bool isSurroundedByBrackets = input.StartsWith("[") && input.EndsWith("]");

                if (bracketExpectation == BracketExpectation.Present)
                    isSuccess = isAddress && isSurroundedByBrackets;
                else
                    isSuccess = isAddress && !isSurroundedByBrackets;

                if (isSuccess)
                    addressSyntax = new AddressSyntax(address, undefinedLabel);
                else
                    addressSyntax = null;

                return isSuccess;
            }
Exemple #3
0
            public static bool TryParseRegister(string input, out RegisterSyntax registerSyntax, BracketExpectation bracketExpectation = BracketExpectation.NotPresent)
            {
                bool isSuccess;

                bool isRegister = Regex.IsMatch(input, @"^\[?R[0-9A-F]\]?$");
                bool isSurroundedByBrackets = input.StartsWith("[") && input.EndsWith("]");

                if (bracketExpectation == BracketExpectation.Present)
                    isSuccess = isRegister && isSurroundedByBrackets;
                else
                    isSuccess = isRegister && !isSurroundedByBrackets;

                if (isSuccess)
                    registerSyntax = new RegisterSyntax(input.Trim('[', ']'));
                else
                    registerSyntax = null;

                return isSuccess;
            }
        public static bool TryParse(string input, SymbolTable symbolTable, out AddressSyntax addressSyntax, BracketExpectation bracketExpectation = BracketExpectation.NotPresent)
        {
            bool isSuccess;

            bool isAddress = IsAddress(input.Trim('[', ']'), symbolTable, out byte address, out string undefinedLabel);

            bool isSurroundedByBrackets = input.StartsWith("[") && input.EndsWith("]");

            if (bracketExpectation == BracketExpectation.Present)
            {
                isSuccess = isAddress && isSurroundedByBrackets;
            }
            else
            {
                isSuccess = isAddress && !isSurroundedByBrackets;
            }

            if (isSuccess)
            {
                addressSyntax = new AddressSyntax(address, undefinedLabel);
            }
            else
            {
                addressSyntax = null;
            }

            return(isSuccess);
        }