Permalink
Browse files

started cleaning up the mess

  • Loading branch information...
1 parent 66c2b6d commit d9a2ee918dabba5832afc52c6ca9d80c358dd464 @tj committed May 8, 2011
Showing with 36 additions and 27 deletions.
  1. +36 −27 src/parser.leg
View
63 src/parser.leg
@@ -145,49 +145,58 @@ end-of-file= !.
%%
-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,

0 comments on commit d9a2ee9

Please sign in to comment.