Пример #1
0
        void parseArgs(IoLexer lexer)
        {
            lexer.pop();

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                IoMessage arg = newParseNextMessageChain(this.state, lexer);
                addArg(arg);

                while (lexer.topType() == IoTokenType.COMMA_TOKEN)
                {
                    lexer.pop();

                    if (lexer.top() != null && lexer.top().isValidMessageName())
                    {
                        IoMessage arg2 = newParseNextMessageChain(this.state, lexer);
                        addArg(arg2);
                    }
                    else
                    {
                    }
                }
            }

            if (lexer.topType() != IoTokenType.CLOSEPAREN_TOKEN)
            {
                // TODO: Exception, missing close paren
            }
            lexer.pop();
        }
Пример #2
0
        IoMessage newParseNextMessageChain(IoState state, IoLexer lexer)
        {
            IoMessage msg = clone(state) as IoMessage;

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseName(state, lexer);
            }

            if (lexer.topType() == IoTokenType.OPENPAREN_TOKEN)
            {
                msg.parseArgs(lexer);
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseNext(lexer);
            }

            while (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();

                if (lexer.top() != null && lexer.top().isValidMessageName())
                {
                    IoMessage eol = IoMessage.newWithName(state, state.semicolonSymbol);
                    msg.next = eol;
                    eol.parseNext(lexer);
                }
            }

            return(msg);
        }
Пример #3
0
        void parseName(IoState state, IoLexer lexer)
        {
            IoToken token = lexer.pop();

            messageName = IoSeq.createSymbolInMachine(state, token.name);
            ifPossibleCacheToken(token);
            //rawSetLineNumber(token.lineNumber);
            //rawSetCharNumber(token.charNumber);
        }
Пример #4
0
        IoMessage newFromTextLabelSymbol(IoState state, string code, IoSeq labelSymbol)
        {
            IoLexer   lexer = new IoLexer();
            IoMessage msg   = new IoMessage();

            msg     = msg.clone(state) as IoMessage;
            lexer.s = code;
            lexer.lex();
            msg = this.newParse(state, lexer);
            msg.opShuffle();
            msg.label = labelSymbol;
            return(msg);
        }
Пример #5
0
        IoMessage newParse(IoState state, IoLexer lexer)
        {
            if (lexer.errorToken != null)
            {
            }

            if (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                IoMessage self = newParseNextMessageChain(state, lexer);
                if (lexer.topType() != IoTokenType.NO_TOKEN)
                {
                    state.error(self, "compile error: %s", "unused tokens");
                }
                return(self);
            }

            return(newWithNameReturnsValue(state, IoSeq.createSymbolInMachine(state, "nil"), state.ioNil));
        }
Пример #6
0
 void parseNext(IoLexer lexer)
 {
     IoMessage nextMessage = newParseNextMessageChain(this.state, lexer);
     this.next = nextMessage;
 }
Пример #7
0
 void parseName(IoState state, IoLexer lexer)
 {
     IoToken token = lexer.pop();
     messageName = IoSeq.createSymbolInMachine(state, token.name);
     ifPossibleCacheToken(token);
     //rawSetLineNumber(token.lineNumber);
     //rawSetCharNumber(token.charNumber);
 }
Пример #8
0
        void parseArgs(IoLexer lexer)
        {
            lexer.pop();

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                IoMessage arg = newParseNextMessageChain(this.state, lexer);
                addArg(arg);

                while (lexer.topType() == IoTokenType.COMMA_TOKEN)
                {
                    lexer.pop();

                    if (lexer.top() != null && lexer.top().isValidMessageName())
                    {
                        IoMessage arg2 = newParseNextMessageChain(this.state, lexer);
                        addArg(arg2);
                    }
                    else
                    {
                    }
                }
            }

            if (lexer.topType() != IoTokenType.CLOSEPAREN_TOKEN)
            {
                // TODO: Exception, missing close paren
            }
            lexer.pop();
        }
Пример #9
0
        IoMessage newParseNextMessageChain(IoState state, IoLexer lexer)
        {
            IoMessage msg = clone(state) as IoMessage;

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseName(state, lexer);
            }

            if (lexer.topType() == IoTokenType.OPENPAREN_TOKEN)
            {
                msg.parseArgs(lexer);
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                msg.parseNext(lexer);
            }

            while (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();

                if (lexer.top() != null && lexer.top().isValidMessageName())
                {
                    IoMessage eol = IoMessage.newWithName(state, state.semicolonSymbol);
                    msg.next = eol;
                    eol.parseNext(lexer);
                }
            }

            return msg;
        }
Пример #10
0
        IoMessage newParse(IoState state, IoLexer lexer)
        {
            if (lexer.errorToken != null)
            {
            }

            if (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                IoMessage self = newParseNextMessageChain(state, lexer);
                if (lexer.topType() != IoTokenType.NO_TOKEN)
                {
                    state.error(self, "compile error: %s", "unused tokens");
                }
                return self;
            }

            return newWithNameReturnsValue(state, IoSeq.createSymbolInMachine(state, "nil"), state.ioNil);
        }
Пример #11
0
 IoMessage newFromTextLabelSymbol(IoState state, string code, IoSeq labelSymbol)
 {
     IoLexer lexer = new IoLexer();
     IoMessage msg = new IoMessage();
     msg = msg.clone(state) as IoMessage;
     lexer.s = code;
     lexer.lex();
     msg = this.newParse(state, lexer);
     msg.opShuffle();
     msg.label = labelSymbol;
     return msg;
 }
Пример #12
0
        void parseNext(IoLexer lexer)
        {
            IoMessage nextMessage = newParseNextMessageChain(this.state, lexer);

            this.next = nextMessage;
        }