[Commit] mint/src mint.5c,1.1,1.2
Bart Massey
commit at keithp.com
Mon Nov 29 14:51:30 PST 2004
Committed by: bart
Update of /local/src/CVS/mint/src
In directory home.keithp.com:/tmp/cvs-serv7597
Modified Files:
mint.5c
Log Message:
Restructure driver slightly to make it easier to load and work with.
Index: mint.5c
===================================================================
RCS file: /local/src/CVS/mint/src/mint.5c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mint.5c 29 Nov 2004 14:53:28 -0000 1.1
+++ mint.5c 29 Nov 2004 22:51:27 -0000 1.2
@@ -40,16 +40,15 @@
*/
-load "mintutil.5c"
-import Mintutil;
-load "lexer_runtime.5c"
-load "parser_runtime.5c"
+autoimport Mintutil;
+library "lexer_runtime.5c"
+library "parser_runtime.5c"
import Mint;
-load "lexer_generator.5c"
-load "parser_generator.5c"
-load "parser_io.5c"
-load "lexer_io.5c"
-load "tnode.5c"
+library "lexer_generator.5c"
+library "parser_generator.5c"
+library "parser_io.5c"
+library "lexer_io.5c"
+library "tnode.5c"
parse_table pgptbl = load_parser("generator_tables/bnftbl.mtp");
parse_table reptbl = load_parser("generator_tables/retbl.mtp");
@@ -389,15 +388,14 @@
return create_parse_table(g);
}
-if(dim(argv) < 2) {
- fprintf(stderr, "Usage: nickle mint.5c grammarfile\n");
-} else {
- file f = open(top(argv), "r");
+void make_parser(string fname) {
+ file f = open(fname, "r");
printf("Parsing File...\n");
try ast a = parse_file(&pgptbl, &pglex, f);
catch syntax_error(&lexer_context lc) {
- printf("Syntax error on line %d -- before %s\n", lc.line_number, get_token(&lc).lexeme);
- exit(1);
+ printf("Syntax error on line %d -- before %s\n",
+ lc.line_number, get_token(&lc).lexeme);
+ exit(1);
}
printf("Node Transform...\n");
t_node tn = t_node_transform(a);
@@ -407,11 +405,18 @@
printf("Generating Parse Table...\n");
try parse_table ptbl = getparser(tn);
catch ambiguous(set[int][string] c) {
- printf("Grammar is ambiguous\n");
- /*conflict_print(c); */
- exit(1);
+ printf("Grammar is ambiguous\n");
+ /*conflict_print(c); */
+ exit(1);
}
- save_parser(ptbl,top(argv) + ".mtp");
- save_lexer(lex, top(argv) + ".mtl");
+ save_parser(ptbl,fname + ".mtp");
+ save_lexer(lex, fname + ".mtl");
}
+if(dim(argv) > 0) {
+ if(dim(argv) < 2) {
+ fprintf(stderr, "Usage: nickle mint.5c grammarfile\n");
+ exit(0);
+ }
+ make_parser(top(argv));
+};
More information about the Commit
mailing list