2 * Copyright 1993, 2000 Christopher Seiwald.
4 * This file is part of Jam - see jam.c for Copyright information.
8 * parse.c - make and destroy parse trees as driven by the parser
10 * 09/07/00 (seiwald) - ref count on PARSE to avoid freeing when used,
11 * as per Matt Armstrong.
12 * 09/11/00 (seiwald) - structure reworked to reflect that (*func)()
14 * 10/22/02 (seiwald) - working return/break/continue statements
15 * 11/04/02 (seiwald) - const-ing for string literals
24 static PARSE
*yypsave
;
27 parse_file( const char *f
)
29 /* Suspend scan of current file */
30 /* and push this new file in the stream */
34 /* Now parse each block of rules and execute it. */
35 /* Execute it outside of the parser so that recursive */
36 /* calls to yyrun() work (no recursive yyparse's). */
42 int jmp
= 0; /* JMP_NONE */
44 /* $(<) and $(>) empty in outer scope. */
48 /* Filled by yyparse() calling parse_save() */
52 /* If parse error or empty parse, outta here */
54 if( yyparse() || !( p
= yypsave
) )
57 /* Run the parse tree. */
59 list_free( (*(p
->func
))( p
, &l
, &jmp
) );
66 parse_save( PARSE
*p
)
73 LIST
*(*func
)( PARSE
*p
, LOL
*args
, int *jmp
),
81 PARSE
*p
= (PARSE
*)malloc( sizeof( PARSE
) );
96 parse_refer( PARSE
*p
)
102 parse_free( PARSE
*p
)
108 freestr( p
->string
);
110 freestr( p
->string1
);
112 parse_free( p
->left
);
114 parse_free( p
->right
);
116 parse_free( p
->third
);
122 const char *multiFormSfx (int cnt
) {
123 return cnt
==1 ? "" : "s";