Пример #1
0
        private static bool IsDelimiterBetweenQuotes(char delimiter, string line, out int delimiterIndex)
        {
            delimiterIndex = line.IndexOf(delimiter);

            foreach (var(leftQuote, rightQuote) in StringLiteralSyntax.GetQuotePairs())
            {
                if (line.IndexOf(leftQuote) < delimiterIndex && delimiterIndex < line.LastIndexOf(rightQuote))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
        private void DataByte(string[] operands)
        {
            bool invalidSyntax = false;

            if (operands.Length == 0)
            {
                invalidSyntax = true;
            }
            else
            {
                foreach (string operand in operands)
                {
                    if (NumberSyntax.TryParse(operand, out byte number))
                    {
                        _bytes.Add(number, _currentLineNumber);
                    }
                    else if (StringLiteralSyntax.TryParse(operand, out string stringLiteral))
                    {
                        foreach (char c in stringLiteral)
                        {
                            _bytes.Add((byte)c, _currentLineNumber);
                        }
                    }
                    else
                    {
                        invalidSyntax = true;
                        break;
                    }
                }
            }

            if (invalidSyntax)
            {
                throw new AssemblyException("Expected a number or string literal.", _currentLineNumber);
            }
        }