Annotation of OpenXM_contrib2/asir2000/parse/parser.c, Revision 1.1.1.1
1.1 noro 1: /* $OpenXM: OpenXM/src/asir99/parse/parser.c,v 1.1.1.1 1999/11/10 08:12:34 noro Exp $ */
2: #include <ctype.h>
3: #include "ca.h"
4: #include "parse.h"
5:
6: extern int main_parser;
7: extern char *parse_strp;
8: extern SNODE parse_snode;
9: extern FUNC parse_targetf;
10:
11: int mainparse(snodep)
12: SNODE *snodep;
13: {
14: int ret;
15:
16: main_parser = 1;
17: ret = yyparse();
18: *snodep = parse_snode;
19: return ret;
20: }
21:
22: int exprparse(f,str,exprp)
23: FUNC f;
24: char *str;
25: FNODE *exprp;
26: {
27: char buf0[BUFSIZ];
28: char *buf;
29: int i,n;
30: char c;
31:
32:
33: n = strlen(str);
34: if ( n >= BUFSIZ )
35: buf = (char *)ALLOCA(n+1);
36: else
37: buf = buf0;
38: for ( i = 0; ; i++, str++ ) {
39: c = *str;
40: if ( !c || c == '\n' ) {
41: buf[i] = ';'; buf[i+1] = 0; break;
42: } else
43: buf[i] = c;
44: }
45: parse_strp = buf;
46: parse_targetf = f;
47: main_parser = 0;
48: if ( yyparse() || !parse_snode || parse_snode->id != S_SINGLE ) {
49: *exprp = 0; return 0;
50: } else {
51: *exprp = (FNODE)FA0(parse_snode); return 1;
52: }
53: }
54:
55: void read_eval_loop() {
56: struct oEGT egt0,egt1;
57: extern int prtime,prresult,ox_do_copy;
58: SNODE snode;
59: double r0,r1;
60: double get_rtime();
61: extern Obj LastVal;
62:
63: LastVal = 0;
64: while ( 1 ) {
65: mainparse(&snode);
66: nextbp = 0;
67: get_eg(&egt0);
68: r0 = get_rtime();
69: LastVal = evalstat(snode);
70: storeans(LastVal);
71: get_eg(&egt1);
72: r1 = get_rtime();
73: if ( !ox_do_copy ) {
74: if ( prresult ) {
75: printexpr(CO,LastVal); putc('\n',asir_out);
76: fflush(asir_out);
77: }
78: if ( prtime ) {
79: printtime(&egt0,&egt1,r1-r0);
80: }
81: prompt();
82: }
83: }
84: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>