示例#1
0
        public void Parse()
        {
            VarParser typeReader = new VarParser(m_reader, false);

            FindValidateWord("//");
            typeReader.Parse("classID");
            TypeID = typeReader.Value;
            FindValidateSymbol(':');

            string typeName = FindReadWord();

            AddType(typeName);

            while (true)
            {
                string arrow = FindReadWord();
                if (arrow == string.Empty)
                {
                    break;
                }

                if (arrow != "<-")
                {
                    throw CreateException($"Can't find arrow word but found {arrow}");
                }

                typeName = FindReadWord();
                AddType(typeName);
            }
        }
        public void Parse()
        {
            VarParser vreader = new VarParser(m_reader, true);

            Validate();

            ReadType();

            VarName = FindReadWord();
            if (VarName == string.Empty)
            {
                throw CreateException("Can't find variable name");
            }

            FindValidateWord("//");

            vreader.Parse("ByteSize");
            Size = vreader.Value;

            FindValidateSymbol(',');

            vreader.Parse("Index");
            Index = vreader.Value;

            FindValidateSymbol(',');

            vreader.Parse("IsArray");
            IsArray = vreader.Value != 0;

            FindValidateSymbol(',');

            vreader.Parse("MetaFlag");
            MetaFlag = (TypeMetaFlag)vreader.Value;

            int childIndent = m_indent + 1;

            while (true)
            {
                int indent = CheckIndent();
                if (indent < childIndent)
                {
                    return;
                }
                if (indent > childIndent)
                {
                    throw CreateException($"Unsupported indent {indent}");
                }

                FindNextLine();
                TypeParser child = new TypeParser(m_reader, childIndent);
                child.Parse();
                m_children.Add(child);
            }
        }
示例#3
0
        public void Parse()
        {
            VarParser vreader = new VarParser(m_reader, true);

            Validate();

            ReadType();

            VarName = string.Empty;
            FindWord();
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                char symb = (char)m_reader.PeekChar();
                if (symb == '/')
                {
                    while (sb[sb.Length - 1] == ' ')
                    {
                        sb.Length--;
                    }
                    break;
                }
                sb.Append(m_reader.ReadChar());
            }
            VarName = sb.ToString();
            if (VarName == string.Empty)
            {
                throw CreateException("Can't find variable name");
            }
            FindValidateWord("//");

            vreader.Parse("ByteSize");
            Size = vreader.Value;

            FindValidateSymbol(',');

            vreader.Parse("Index");
            Index = vreader.Value;

            FindValidateSymbol(',');

            vreader.Parse("Version");
            Version = vreader.Value;

            FindValidateSymbol(',');

            vreader.Parse("IsArray");
            IsArray = vreader.Value != 0;

            FindValidateSymbol(',');

            vreader.Parse("MetaFlag");
            MetaFlag = (TypeMetaFlag)vreader.Value;

            int childIndent = m_indent + 1;

            while (true)
            {
                int indent = CheckIndent();
                if (indent < childIndent)
                {
                    return;
                }
                if (indent > childIndent)
                {
                    throw CreateException($"Unsupported indent {indent}");
                }

                FindNextLine();
                TypeParser child = new TypeParser(m_reader, childIndent);
                child.Parse();
                m_children.Add(child);
            }
        }