Пример #1
0
        public void FastStirngBuilder_ShouldEqualsWork()
        {
            var builder = new FastStringBuilder();

            builder.Append("Test");

            Assert.IsTrue(builder.Equals("Test"));
            Assert.IsFalse(builder.Equals("Tes"));
            Assert.IsFalse(builder.Equals("Test1"));
        }
Пример #2
0
        public static StepTokenKind ReadNext(FastBinaryReader reader, FastStringBuilder buffer)
        {
            int current;

            while ((current = reader.Read()) != -1)
            {
                var ch = (char)current;

                switch (ch)
                {
                case '0':
                case '1':
                case '2':
                case '3':
                case '4':
                case '5':
                case '6':
                case '7':
                case '8':
                case '9':
                {
                    buffer.Clear();

                    buffer.Append(ch);
                    return(ParseNumberKind(reader, buffer));
                };

                case '-':
                case '+':
                {
                    if (IsDigit(reader.Peek()))
                    {
                        buffer.Clear();

                        buffer.Append(ch);
                        return(ParseNumberKind(reader, buffer));
                    }
                    else
                    {
                        throw new UnexpectedCharacterException(ch);
                    }
                }

                case '#':
                {
                    if (!IsDigit(reader.Peek()))
                    {
                        throw new UnexpectedCharacterException(ch);
                    }

                    buffer.Clear();

                    do
                    {
                        buffer.Append((char)reader.Read());
                    }while (IsDigit(reader.Peek()));

                    return(StepTokenKind.EntityInstanceName);
                }

                case '"':
                {
                    throw new NotImplementedException("binary");
                }

                case '\'':
                {
                    buffer.Clear();

                    return(ParseStringKind(reader, buffer));
                }

                case '!':
                {
                    throw new NotImplementedException("user defined keyword");
                }

                case '.':
                {
                    if (!IsUpper(reader.Peek()))
                    {
                        throw new UnexpectedCharacterException(ch);
                    }

                    buffer.Clear();

                    do
                    {
                        buffer.Append((char)reader.Read());
                    } while (IsUpperOrDigit(reader.Peek()));

                    if (reader.Peek() == '.')
                    {
                        reader.Read();
                        return(StepTokenKind.Enumeration);
                    }
                    else
                    {
                        throw new UnexpectedCharacterException((char)reader.Peek());
                    }
                }

                case '=':
                    return(StepTokenKind.Assignment);

                case '*':
                    return(StepTokenKind.Asterisk);

                case '$':
                    return(StepTokenKind.Dollar);

                case ';':
                    return(StepTokenKind.Semicolon);

                case '(':
                    return(StepTokenKind.LeftParen);

                case ')':
                    return(StepTokenKind.RightParen);

                case '/':
                {
                    if (reader.Peek() == '*')
                    {
                        while ((current = reader.Read()) != -1)
                        {
                            if (current == '*' && reader.Peek() == '/')
                            {
                                reader.Read();
                                break;
                            }
                        }
                    }
                    else
                    {
                        return(StepTokenKind.Solidus);
                    }
                }
                break;

                case ',':
                    return(StepTokenKind.Comma);

                case ' ':
                    break;

                default:
                {
                    if (IsUpper(ch))
                    {
                        buffer.Clear();

                        buffer.Append(ch);
                        while (IsUpperOrDigitOrMinus(reader.Peek()))
                        {
                            buffer.Append((char)reader.Read());
                        }

                        if (buffer.Equals("ISO-10303-21"))
                        {
                            return(StepTokenKind.Iso);
                        }
                        else if (buffer.Equals("END-ISO-10303-21"))
                        {
                            return(StepTokenKind.EndIso);
                        }
                        else if (buffer.Equals("HEADER"))
                        {
                            return(StepTokenKind.Header);
                        }
                        else if (buffer.Equals("ENDSEC"))
                        {
                            return(StepTokenKind.EndSection);
                        }
                        else if (buffer.Equals("DATA"))
                        {
                            return(StepTokenKind.Data);
                        }
                        else
                        {
                            return(StepTokenKind.StandardKeyword);
                        }
                    }
                    else if (IsCharacter(ch))
                    {
                        throw new UnexpectedCharacterException(ch);
                    }

                    break;
                }
                }
            }

            return(StepTokenKind.Eof);
        }
Пример #3
0
 public bool Equals(string value)
 {
     return(StringBuilder.Equals(value));
 }