Sunday, July 17, 2005

Experiments with syntax highlighting

I have been posting code for a while now, I want to try and post good looking code - which is syntax highlighted.

Here is the first attempt


/*
* Simple program to parse regular expressions
* (C) Balbir Singh
* Permission to copy the program if and only if the (C) is
* maintained.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <bitset>
#include <iostream>
#include <queue>
using namespace std;

static bool status = true;

#ifdef DEBUG
#define debug(x...) {\
printf("%s:%d ", __FUNCTION__, __LINE__); \
printf(x); \
}
#else
#define debug(x...)
#endif

#define pcr debug("current token is %c\n", s[idx]);
#define perr {\
fprintf(stderr, "%s:%d parse error at token is %c\n", \
__PRETTY_FUNCTION__, __LINE__, s[idx-1]); \
status = false; \
};

2 comments:

Gops said...

Ballu,

Please don't put code - it makes me scroll for like eternity, and still I haven't got anything out of it. How about code snippets - or why don't you link it from an other page?

BTW, the font size too makes it hard to read (particularly on IE)

Balbir said...

Good point, I am fixing it right away. The test passed (or failed) I guess.

Ranking and Unranking permutations

I've been a big fan of Skiena's Algorithm Design Manual , I recently found my first edition of the book (although I own the third ed...