Exemplo n.º 1
0
int lexdump(const char* filename)
{
	FlowLexer lexer;
	std::fstream input(filename);
	if (!lexer.initialize(&input, filename))
		return 1;

	for (FlowToken t = lexer.token(); t != FlowToken::Eof; t = lexer.nextToken()) {
		SourceLocation location = lexer.location();
		std::string ts = lexer.tokenToString(t);
		std::string raw = lexer.locationContent();

		printf("[%04ld:%03ld.%03ld - %04ld:%03ld.%03ld] (%s): %s\n",
			location.begin.line, location.begin.column, location.begin.offset,
			location.end.line, location.end.column, location.end.offset,
			ts.c_str(), raw.c_str());
	}

	return 0;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
	FlowLexer lexer;
	std::fstream input(argv[1]);
	if (!lexer.initialize(&input))
		return 1;

	for (FlowToken t = lexer.token(); t != FlowToken::Eof; t = lexer.nextToken())
	{
		SourceLocation location = lexer.location();
		std::string ts = lexer.tokenToString(t);
		std::string raw = lexer.locationContent();

		printf("[%04ld:%03ld.%03ld - %04ld:%03ld.%03ld] (%s): %s\n",
			location.begin.line, location.begin.column, location.begin.offset,
			location.end.line, location.end.column, location.end.offset,
			ts.c_str(), raw.c_str());
	}

	return true;
}