Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 8, 2011
1 parent d9a2ee9 commit a6c62ee
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
63 changes: 36 additions & 27 deletions src/parser.c
Expand Up @@ -976,49 +976,58 @@ YY_PARSE(void) YY_NAME(parse_free)(CDESCENT *G)
#endif


void yyerror(struct _CDESCENT *G, char *message)
{
void
yyerror(struct _CDESCENT *G, char *message) {
fprintf(stderr, "%s:%d: %s", filename, lineNumber, message);
if (G->text[0]) fprintf(stderr, " near token '%s'", G->text);
if (G->pos < G->limit || !feof(input))
{
G->buf[G->limit]= '\0';
fprintf(stderr, " before text \"");
while (G->pos < G->limit)
{
if ('\n' == G->buf[G->pos] || '\r' == G->buf[G->pos]) break;
fputc(G->buf[G->pos++], stderr);
}
if (G->pos == G->limit)
{
int c;
while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
fputc(c, stderr);
}
fputc('\"', stderr);
if (G->pos < G->limit || !feof(input)) {
G->buf[G->limit]= '\0';
fprintf(stderr, " before text \"");

while (G->pos < G->limit) {
if ('\n' == G->buf[G->pos] || '\r' == G->buf[G->pos]) break;
fputc(G->buf[G->pos++], stderr);
}

if (G->pos == G->limit) {
int c;
while (EOF != (c= fgetc(input)) && '\n' != c && '\r' != c)
fputc(c, stderr);
}

fputc('\"', stderr);
}

fprintf(stderr, "\n");
exit(1);
}

void makeHeader(char *text)
{
Header *header= (Header *)malloc(sizeof(Header));
header->text= strdup(text);
header->next= headers;
headers= header;
void
makeHeader(char *text) {
Header *header = (Header *)malloc(sizeof(Header));
header->text = strdup(text);
header->next = headers;
headers = header;
}

void makeTrailer(char *text)
{
trailer= strdup(text);
void
makeTrailer(char *text) {
trailer = strdup(text);
}

/*
* Output cDescent version.
*/

static void
version() {
printf("%s\n", CDESCENT_VERSION);
}

/*
* Output usage information.
*/

static void
usage(char *name) {
fprintf(stderr,
Expand Down
4 changes: 4 additions & 0 deletions src/parser.leg
Expand Up @@ -218,6 +218,10 @@ usage(char *name) {
exit(1);
}

/*
* Parse arguments.
*/

int
main(int argc, char **argv) {
CDESCENT *G;
Expand Down

0 comments on commit a6c62ee

Please sign in to comment.