示例#1
0
        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);
        }
示例#2
0
 public InstructionByte(AddressSyntax address, int lineNumber)
 {
     _address = address;
     if (address.ContainsUndefinedLabel)
     {
         _addressType = AddressType.Label;
     }
     else
     {
         _addressType = AddressType.DirectValue;
         _byte        = _address.Value;
     }
     _lineNumber = lineNumber;
 }
示例#3
0
 public InstructionByte(AddressSyntax address)
 {
     _address = address;
     if (address.ContainsUndefinedLabel)
         _addressType = AddressType.Label;
     else
     {
         _addressType = AddressType.DirectValue;
         _byte = _address.Value;
     }
 }
示例#4
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;
            }