コード例 #1
0
        private void ClassBody(ClassStruct element)
        {
            Match(TokenType.OpenBrace);

            while (Next().type != TokenType.CloseBraceSemicolon)
            {
                if (Next().type == TokenType.PrivateKeyword)
                {
                    Match(TokenType.PrivateKeyword);
                    element.privateMembers.AddRange(Members());
                }
                else if (Next().type == TokenType.PublicKeyword)
                {
                    Match(TokenType.PublicKeyword);
                    element.publicMembers.AddRange(Members());
                }
                else if (Next().type == TokenType.ProtectedKeyword)
                {
                    Match(TokenType.ProtectedKeyword);
                    element.protectedMembers.AddRange(Members());
                }
                else
                {
                    element.freeMembers.AddRange(Members());
                }
            }

            Match(TokenType.CloseBraceSemicolon);
        }
コード例 #2
0
        private ClassStruct ClassStruct()
        {
            Token _proto = Next();

            Match(TokenType.ClassStructProto);
            var    match = Regex.Match(_proto.value, "(class|struct)( )+[_a-zA-Z0-9]+");
            string _name = match.Value.Replace("class", "").Replace("struct", "").Trim(' ');

            if (_proto.value.StartsWith("class"))
            {
                classStructPrototypes.Add("class " + _name);
            }
            else
            {
                classStructPrototypes.Add("struct " + _name);
            }

            ClassStruct element = new ClassStruct()
            {
                proto = _proto.value, name = _name
            };

            ClassBody(element);

            return(element);
        }