home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / kvik / src / kvik.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-02  |  1.2 KB  |  55 lines  |  [TEXT/MPS ]

  1. /** kvik.c
  2.  ** Kvikkalkul Compiler.
  3.  **
  4.  ** Written by and Copyright 1994 Asher Hoskins.
  5.  **
  6.  ** The author retains copyright on this implementation. Permission for
  7.  ** educational and non-profit use is granted to all. If you're planning to
  8.  ** make money with this or any code derived from it, check with the author
  9.  ** first.
  10.  **
  11.  ** Main routine.
  12.  **/
  13.  
  14. /*    Modifications for Metrowerks C and PowerMac by Brian Connors 
  15.  *    (and I haven't made many)
  16.  *
  17.  *    This code probably doesn't like Think C very much.  Fair warning.
  18.  */
  19.  
  20. #include <stdio.h>
  21. #include "compile.h"
  22. #include <SIOUX.h>  /* CodeWarrior doesn't do command lines without a little coaxing */
  23.  
  24. int main(int argc, char *argv[])
  25. {
  26.     FILE *inp, *out;
  27.     char line[MAXLINELENGTH+2];        /* +2 to simplify token matching */
  28.     int linenum = 1;
  29.  
  30.     if (argc > 1) {
  31.         if ((inp = fopen(argv[1], "r")) == NULL) {
  32.             fprintf(stderr, "kvik: Cannot open '%s'\n", argv[1]);
  33.             exit(1);
  34.         }
  35.         if ((out = fopen("k.out.c", "w")) == NULL) {
  36.             fputs("kvik: Cannot create 'k.out'\n", stderr);
  37.             exit(1);
  38.         }
  39.     }
  40.     else {
  41.         inp = stdin;
  42.         out = stdout;
  43.     }
  44.  
  45.     start_compile(out, argc, argv);
  46.     while (fgets(line, MAXLINELENGTH, inp) != NULL) {
  47.         compile_line(line, out, linenum);
  48.         linenum++;
  49.     }
  50.     end_compile(out);
  51.  
  52.     return(0);
  53. }
  54.  
  55.