~ubuntu-branches/ubuntu/breezy/malaga/breezy

« back to all changes in this revision

Viewing changes to malrul.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2005-01-10 11:52:04 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110115204-hpgncw5pb0m1t8i6
Tags: 6.13-5
debian/control (malaga-doc Recommends): Suggest gv as a
postscript-viewer instead of ghostview.  (Closes: #289701).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 1995 Bjoern Beutel. */
 
2
 
 
3
/* Description. =============================================================*/
 
4
 
 
5
/* This program takes a rule file and compiles it to an intermediate code 
 
6
 * file. */
 
7
 
 
8
/* Includes. ================================================================*/
 
9
 
 
10
#include <stdio.h>
 
11
#include <stdarg.h>
 
12
#include <string.h>
 
13
#include <stdlib.h>
 
14
#include <time.h>
 
15
#include <locale.h>
 
16
#include <setjmp.h>
 
17
#include "basic.h"
 
18
#include "pools.h"
 
19
#include "values.h"
 
20
#include "symbols.h"
 
21
#include "scanner.h"
 
22
#include "files.h"
 
23
#include "rule_type.h"
 
24
#include "rule_code.h"
 
25
#include "rule_compiler.h"
 
26
#include "patterns.h"
 
27
#include "hangul.h"
 
28
 
 
29
/* Functions. ===============================================================*/
 
30
 
 
31
int 
 
32
main( int argc, char *argv[] )
 
33
/* The main function of "malrul". */
 
34
{
 
35
  string_t rule_file, object_file, symbol_file;
 
36
  int_t file_type = 0, i;
 
37
 
 
38
  init_basic( "malrul" );
 
39
  if (argc == 2) 
 
40
  { 
 
41
    if (strcmp_no_case( argv[1], "--version" ) == 0
 
42
        || strcmp_no_case( argv[1], "-version" ) == 0
 
43
        || strcmp_no_case( argv[1], "-v" ) == 0) 
 
44
    { 
 
45
      program_message();
 
46
      exit(0);
 
47
    } 
 
48
    else if (strcmp_no_case( argv[1], "--help" ) == 0
 
49
             || strcmp_no_case( argv[1], "-help" ) == 0
 
50
             || strcmp_no_case( argv[1], "-h" ) == 0) 
 
51
    { 
 
52
      printf( "Compile a rule file of a Malaga grammar.\n\n"
 
53
              "Usage:\n"
 
54
              "malrul SYM_FILE RULE_FILE "
 
55
              "-- Compile RULE_FILE using SYM_FILE.\n"
 
56
              "malrul -v[ersion]         "
 
57
              "-- Print version information.\n"
 
58
              "malrul -h[elp]            "
 
59
              "-- Print this help.\n\n"
 
60
              "SYM_FILE may end on \".sym\" or \".esym\".\n"
 
61
              "RULE_FILE may end on \".all\", \".mor\", or \".syn\".\n" );
 
62
      exit(0);
 
63
    }
 
64
  }
 
65
  rule_file = object_file = symbol_file = NULL;
 
66
  for (i = 1; i < argc; i++) 
 
67
  { 
 
68
    if (has_extension( argv[i], "all" )) 
 
69
    { 
 
70
      set_file_name( &rule_file, argv[i] );
 
71
      set_binary_file_name( &object_file, argv[i] );
 
72
      file_type = ALLO_RULE_FILE;
 
73
    } 
 
74
    else if (has_extension( argv[i], "mor" )) 
 
75
    { 
 
76
      set_file_name( &rule_file, argv[i] );
 
77
      set_binary_file_name( &object_file, argv[i] );
 
78
      file_type = MORPHO_RULE_FILE;
 
79
    }
 
80
    else if (has_extension( argv[i], "syn" )) 
 
81
    { 
 
82
      set_file_name( &rule_file, argv[i] );
 
83
      set_binary_file_name( &object_file, argv[i] );
 
84
      file_type = SYNTAX_RULE_FILE;
 
85
    }
 
86
    else if (has_extension( argv[i], "sym" )) 
 
87
      set_binary_file_name( &symbol_file, argv[i] );
 
88
    else if (has_extension( argv[i], "esym" ))
 
89
      set_binary_file_name( &symbol_file, argv[i] );
 
90
    else 
 
91
      complain( "Illegal argument \"%s\".", argv[i] );
 
92
  }
 
93
  if (object_file == NULL) 
 
94
    complain( "No file to compile." );
 
95
  if (symbol_file == NULL) 
 
96
    complain( "Missing symbol file name." );
 
97
 
 
98
  init_values();
 
99
  init_symbols( symbol_file );
 
100
  init_hangul();
 
101
  init_scanner();
 
102
 
 
103
  compile_rule_file( rule_file, object_file, file_type );
 
104
 
 
105
  terminate_hangul();
 
106
  terminate_symbols();
 
107
  terminate_values();
 
108
  terminate_scanner();
 
109
  terminate_patterns();
 
110
  free_mem( &symbol_file );
 
111
 
 
112
  free_mem( &object_file );
 
113
  free_mem( &rule_file );
 
114
  terminate_basic();
 
115
 
 
116
  return 0;
 
117
}
 
118
 
 
119
/* End of file. =============================================================*/