Example #1
0
File: IoLexer.c Project: Akiyah/io
int IoLexer_readTerminator(IoLexer *self)
{
	int terminated = 0;
	IoLexer_pushPos(self);
	IoLexer_readSeparator(self);

	while (IoLexer_readTerminatorChar(self))
	{
		terminated = 1;
		IoLexer_readSeparator(self);
	}

	if (terminated)
	{
		IoToken *top = IoLexer_currentToken(self);

		// avoid double terminators
		if (top && IoToken_type(top) == TERMINATOR_TOKEN)
		{
			return 1;
		}

		IoLexer_addTokenString_length_type_(self, ";", 1, TERMINATOR_TOKEN);
		IoLexer_popPos(self);
		return 1;
	}

	IoLexer_popPosBack(self);
	return 0;
}
Example #2
0
void IoMessage_ifPossibleCacheToken_(IoMessage *self, IoToken *p)
{
	IoSymbol *method = DATA(self)->name;
	IoObject *r = NULL;

	switch ((int)IoToken_type(p))
	{
		case TRIQUOTE_TOKEN:
			r =  IoSeq_rawAsUntriquotedSymbol(method);
			break;

		case MONOQUOTE_TOKEN:
			r =  IoSeq_rawAsUnescapedSymbol(IoSeq_rawAsUnquotedSymbol(method));
			break;

		case NUMBER_TOKEN:
			r =  IONUMBER(IoSeq_asDouble(method));
			break;

		case HEXNUMBER_TOKEN:
			r =  IONUMBER(IoSeq_rawAsDoubleFromHex(method));
			break;

		default:
			if (IoSeq_rawEqualsCString_(method, "nil"))
			{
				r = IONIL(self);
			}
			else if (IoSeq_rawEqualsCString_(method, "true"))
			{
				r = IOTRUE(self);
			}
			else if (IoSeq_rawEqualsCString_(method, "false"))
			{
				r = IOFALSE(self);
			}
	}

	IoMessage_cachedResult_(self, r);
}