Exemple #1
0
        public void ReadKeyword(string keyword)
        {
            VrmlToken token = ReadNextToken();

            if (token.Type != VrmlTokenType.Word || token.Text != keyword)
            {
                throw new InvalidVrmlSyntaxException(keyword + " expected");
            }
        }
Exemple #2
0
        public VrmlToken ReadNextToken()
        {
            VrmlToken token = null;

            if (m_queue.Count > 0)
            {
                token = m_queue.Dequeue();
            }
            else
            {
                token = m_tokenizer.ReadNextToken();
            }
            return(token);
        }
Exemple #3
0
        public void Visit(SFNode field)
        {
            VrmlToken token = m_context.PeekNextToken();

            switch (token.Text)
            {
            case "NULL":
                field.Node = null;
                break;

            default:
                m_context.PushNodeContainer(field);
                m_nodeStatementParser(m_context);
                m_context.PopNodeContainer();
                break;
            }
        }
Exemple #4
0
        protected virtual void ParseMField(Action <ParserContext> itemParser)
        {
            VrmlToken next = m_context.PeekNextToken();

            if (next.Type == VrmlTokenType.OpenBracket)
            {
                next = m_context.ReadNextToken();
                while (true)
                {
                    next = m_context.PeekNextToken();
                    if (next.Type == VrmlTokenType.CloseBracket)
                    {
                        break;
                    }
                    itemParser(m_context);
                }
                next = m_context.ReadNextToken();
            }
            else
            {
                itemParser(m_context);
            }
        }
Exemple #5
0
        protected virtual void ParseScriptBodyElement(ParserContext context)
        {
            var       token   = context.PeekNextToken();
            VrmlToken tokenIs = null;
            string    fieldType;

            switch (token.Text)
            {
            case "eventIn":
                tokenIs = context.PeekNextToken(3);
                if (tokenIs.Text == "IS")
                {
                    token     = context.ReadNextToken();
                    fieldType = ParseFieldType(context);
                    string eventInId1 = ParseEventInId(context);
                    tokenIs = context.ReadNextToken();
                    string eventInId2 = ParseEventInId(context);
                }
                else
                {
                    ParseRestrictedInterfaceDeclaration(context);
                }
                break;

            case "eventOut":
                tokenIs = context.PeekNextToken(3);
                if (tokenIs.Text == "IS")
                {
                    token     = context.ReadNextToken();
                    fieldType = ParseFieldType(context);
                    string eventOutId1 = ParseEventOutId(context);
                    tokenIs = context.ReadNextToken();
                    string eventOutId2 = ParseEventOutId(context);
                }
                else
                {
                    ParseRestrictedInterfaceDeclaration(context);
                }
                break;

            case "field":
                tokenIs = context.PeekNextToken(3);
                if (tokenIs.Text == "IS")
                {
                    token     = context.ReadNextToken();
                    fieldType = ParseFieldType(context);
                    string fieldId1 = ParseFieldId(context);
                    tokenIs = context.ReadNextToken();
                    string fieldId2 = ParseFieldId(context);
                }
                else
                {
                    ParseRestrictedInterfaceDeclaration(context);
                }
                break;

            default:
                if (token.Type == VrmlTokenType.Word)
                {
                    ParseNodeBodyElement(context);
                }
                else
                {
                    throw new Exception("Unexpected context");
                }
                break;
            }
        }