%s%s%s", BKW, yytext, EKW); }; process { register int c; register int i=0; printf("%s%s%s", BKW, yytext, EKW); while ( (c=input()) == ' ' || (c == '\t') ) printf(" "); /* Get process names */ proctable[numproc][i++]=c; while ( ((c=input())=='_') || isalnum(c) ) proctable[numproc][i++]=c; proctable[numproc][i++]='\0'; printf("%s%s%s%c", BPN, proctable[numproc], proctable[numproc], EPN, c); numproc++; }; type { register int c; register int i=0; printf("%s%s%s", BKW, yytext, EKW); while ( (c=input()) == ' ' || (c == '\t') ) printf(" "); /* Get type names */ typetable[numtype][i++]=c; while ( ((c=input())=='_') || isalnum(c) ) typetable[numtype][i++]=c; proctable[numtype][i++]='\0'; printf("%s%s%s%c", BTN, typetable[numtype], typetable[numtype], ETN, c); numtype++; }; Boolean|Bool|FBoolean|FBool|Element|Set|BasicEmptyString|NonEmptyString|RicherNonEmptyString|String0|String1|String|BasicNaturalNumber|Nat|NaturalNumber|NatRepresentations|HexNatRepr|HexString|HexDigit|DecNatRepr|DecString|DecDigit|OctNatRepr|OctString|OctDigit|BitNatRepr|BitString|Bit|Octet|OctetString { /* ADT Type from International Standards */ printf("%s%s%s", BTIS, yytext, ETIS); }; "(*" { /* COMMENTS */ register int c; printf("%s(*", BCOM); for ( ; ; ) { while ( (c = input()) != '*' && c != EOF ) switch (c) { case '\t' : printf(" "); break; case '<' : printf("<"); break; case '>' : printf(">"); break; case '&' : printf("&"); break; case '\"' : printf("""); break; default : printf("%c", c); }; /* text comment */ if ( c == '*' ) { printf("*"); while ( (c = input()) == '*' ) printf("*"); if ( c == ')' ) { /* End of comment */ printf(")%s", ECOM); break; } else switch (c) { case '\t' : printf(" "); break; case '<' : printf("<"); break; case '>' : printf(">"); break; case '&' : printf("&"); break; case '\"' : printf("""); break; default : printf("%c", c); }; /* Comment body chracter */ } if ( c == EOF ) { fprintf(stderr, "Warning: EOF in comment."); printf(")%s", ECOM); break; } } } [a-z0-9_][a-z0-9_]* { /* IDENTIFIERS */; printf("%s", yytext); }; %% /**************************************************************/ int id_cmp(const void *j, const void *k) /* Compares two identifiers. Used by qsort. */ { return strnicmp(j, k, IDENTIFIERLENGTH); } /**************************************************************/ int get_tags(def_file_name) char *def_file_name; /* HTML tags definitions */ { FILE *def_file; char tag[128], value[128]; int register i; int register j; /* Open definition file */ if ((def_file = fopen(def_file_name, "r")) == NULL) { fprintf(stderr, "Warning: Unknown definition file. Using internal defaults.\n\n"); return(0); } /* Parse and adjust tag variables */ while (!feof(def_file)) { i=0; tag[i]=fgetc(def_file); switch (tag[i]) { case ' ' : case '\t': case '\n': break; case ';' : /* comment */ while (fgetc(def_file) != '\n'); break; case 'E' : case 'B' : /* Tag name */ while ( isalpha(tag[++i]=fgetc(def_file)) ); if (tag[i]!='\n') while (fgetc(def_file) != '\n'); tag[i]='\0'; /* Get value */ j = 0; while ( (value[j++]=fgetc(def_file)) != '\n' ); value[j-1]='\0'; fprintf(stderr, "TAG CHANGED: %s=%s\n", tag, value); if (!strcmp(tag, "BKW")) strcpy(BKW, value); else if (!strcmp(tag, "EKW")) strcpy(EKW, value); else if (!strcmp(tag, "BCOM")) strcpy(BCOM, value); else if (!strcmp(tag, "ECOM")) strcpy(ECOM, value); else if (!strcmp(tag, "BPN")) strcpy(BPN, value); else if (!strcmp(tag, "EPN")) strcpy(EPN, value); else if (!strcmp(tag, "BTN")) strcpy(BTN, value); else if (!strcmp(tag, "ETN")) strcpy(ETN, value); else if (!strcmp(tag, "BTIS")) strcpy(BTIS, value); else if (!strcmp(tag, "ETIS")) strcpy(ETIS, value); else fprintf(stderr, "Warning: error in definition file on \"%s\".\n", tag); break; default : if (isalnum(tag[i])) fprintf(stderr, "Warning: error in definition file on '%c'.\n", tag[i]); } } fclose(def_file); return(0); } /**************************************************************/ main( argc, argv ) int argc; char **argv; { int register i; char title[128]="Untitled"; /* SDTIN or file? */ ++argv, --argc; /* skip over program name */ yyin = stdin; if ( argc > 0 ) if (strnicmp(argv[0], "-h", 2)) { if (!strnicmp(argv[0], "-d", 2)) { get_tags(argv[1]); if (argc > 2) if ((yyin = fopen( argv[2], "r" ))==NULL) { fprintf(stderr, "Unknown input file. Translation aborted.\n\n"); exit(0); } else strcpy(title, argv[2]); } else if ((yyin = fopen( argv[0], "r" ))==NULL) { fprintf(stderr, "Unknown input file. Translation aborted.\n\n"); exit(0); } else strcpy(title, argv[0]); } else /* HELP FILE */ { printf("\n\tlot2html, by Daniel Amyot (damyot@csi.uottawa.ca).\n"); printf("\tVersion %s, %s\n\n", VERSION, TODAY); printf("\tUsage: lot2html [-d DefFile] [InFile] [>OutFile]\n"); printf("\t lot2html -h (get this help file)\n\n"); printf("\tWhere: DefFile = Definition file (HTML tags). Internal default values.\n"); printf("\t InFile = Input file (in LOTOS). Default is stdin\n"); printf("\t OutFile = Output file (in HTML). Default is stdout\n"); printf("\tSee also the configuration file: lot2html.def\n\n"); exit(0); } /* Header */ printf("\n"); printf("\n
\n", (argc>0?argv[0]:"STDIN") ); printf("\n", VERSION); printf("\n"); time(&timer); date_time=localtime(&timer); printf("\n", asctime(date_time)); printf("\t\n
\n"); yylex(); printf("\n
\n
\n
\n\n", VERSION, asctime(date_time) ); }