/* This is the parser for the dlg
* This is a part of the Purdue Compiler Construction Tool Set
*
* SOFTWARE RIGHTS
*
* We reserve no LEGAL rights to the Purdue Compiler Construction Tool
* Set (PCCTS) -- PCCTS is in the public domain. An individual or
* company may do whatever they wish with source code distributed with
* PCCTS or the code generated by PCCTS, including the incorporation of
* PCCTS, or its output, into commerical software.
*
* We encourage users to develop software with PCCTS. However, we do ask
* that credit is given to us for developing PCCTS. By "credit",
* we mean that if you incorporate our source code into one of your
* programs (commercial product, research project, or otherwise) that you
* acknowledge this fact somewhere in the documentation, research report,
* etc... If you like PCCTS and have developed a nice tool with the
* output, please mention that you developed it using PCCTS. In
* addition, we ask that this header remain intact in our source code.
* As long as these guidelines are kept, we expect to continue enhancing
* this system and expect to make other tools available as they are
* completed.
*
* DLG 1.33
* Will Cohen
* With mods by Terence Parr; AHPCRC, University of Minnesota
* 1989-1995
*/
#header <<
#include "dlg.h"
>>
<<
/* MR20 G. Hobbelt
Fix for Borland C++ 4.x & 5.x compiling with ALL warnings enabled
*/
in set */
int flag_paren = FALSE;
int flag_brace = FALSE;
>>
#lexaction <<
int func_action; /* should actions be turned into functions?*/
/* MR1 */
/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
/* MR1 via <<%%lexmember...>> */
/* MR1 */
void xxputc(int c) { /* MR1 */
#else
void xxputc(c) /* MR1 */
int c; /* MR1 */
{ /* MR1 */
if (parserClass) { /* MR1 */
*pClassName++=c; /* MR1 */
} else { /* MR1 */
}; /* MR1 */
} /* MR1 */
#else
char *format; /* MR1 */
char *string; /* MR1 */
{ /* MR1 */
} else { /* MR1 */
}; /* MR1 */
} /* MR1 */
>>
p_class_def1(); /* MR1 */
}; /* MR1 */
>> /* MR1 */
>> /* MR1 */
<< if (func_action)
>>
/* MR1 */
/* MR1 10-Apr-97 MR1 Allow #token regular expressions to cross lines */
/* MR1 */
/* NOTE: this takes ANYTHING after the \ */
/* NOTE: this takes ANYTHING that doesn't match the other tokens */
<<if ( gen_cpp ) p_includes();>>
(ACTION)* "@"
;
;
<<
if (comp_level)
nfa_to_dfa($1.l);
++mode_counter;
func_action = FALSE;
>>
;
(rule
t1 = new_nfa_node();
/* all accept nodes "dead ends" */
}
>>
)*
| /* empty */
<<$$.l = new_nfa_node(); $$.r = NULL;
>>
;
}
>>
| ACTION
>>
;
if ($2.r) {
}
}
>>
)*
;
<<
$$.l=$1.l; $$.r=$1.r;
>>
/* MR23 */ << if ($$.r != NULL) {
$$.r=$1.r;
}
>>
)*
;
}
>>
| ONE_MORE
}
| ONE_MORE
;
expr : << $$.l = new_nfa_node();
$$.r = new_nfa_node();
>>
<<
/* MR23 */ if ($$.l != NULL) {
($$.l)->trans[0] = $$.r;
}
>>
<<
/* MR23 */ if ($$.l != NULL) {
($$.l)->trans[0] = $$.r;
}
>>
<<
/* MR23 */ if ($$.l != NULL) {
if ($2.r) {
}
}
>>
<<
/* MR23 */ if ($$.l != NULL) {
($$.l)->trans[1] = $$.r;
if ($2.r) {
}
}
>>
| atom
<<
/* MR23 */ if ($$.l != NULL) {
($$.l)->trans[0] = $$.r;
}
>>
;
;
>>
&($$.label));
&($$.label));
>>
<< if (case_insensitive){
}
/* check to see if range okay */
{
int debugLetter1 = $$.letter;
}
}
&($$.label));
&($$.label));
}
>>
}
;
&($$.label));
&($$.label));
>>
;
/* NOTE: LEX_EOF is ALWAYS shifted to 0 = MIN_CHAR - MIN_CHAR*/
;
<</* empty action */>>
/* MR1 */
/* MR1 11-Apr-97 Provide mechanism for inserting code into DLG class */
/* MR1 via <<%%lexmember ...>> */
/* MR1 This is a consequence of not saving actions */
/* MR1 */
>>
>> /* MR1 */
>> /* MR1 */
/* MR1 */
>> /* MR1 */
/* MR1 */
>> /* MR1 */
<<
/* adds a new nfa to the binary tree and returns a pointer to it */
nfa_node *
new_nfa_node(void)
#else
{
if (nfa_size<=nfa_allocated){
/* need to redo array */
if (!nfa_array){
/* need some to do inital allocation */
nfa_size);
}else{
/* need more space */
}
}
/* fill out entry in array */
nfa_array[nfa_allocated] = t;
*t = nfa_model_node;
t->node_no = nfa_allocated;
return t;
}
/* initialize the model node used to fill in newly made nfa_nodes */
void
make_nfa_model_node(void)
#else
{
}
>>
<<
/* print out the pointer value and the node_number */
void
#else
fprint_dfa_pair(f, p)
FILE *f;
nfa_node *p;
{
if (p){
}else{
fprintf(f, "(nil)");
}
}
/* print out interest information on a set */
void
#else
fprint_set(f,s)
FILE *f;
set s;
{
unsigned int *x;
fprintf(f, "n = %d,", s.n);
if (s.setword){
/* print out all the elements in the set */
x = set_pdq(s);
while (*x!=nil){
fprintf(f, "%d ", *x);
++x;
}
}else{
fprintf(f, "setword = (nil)");
}
}
/* code to be able to dump out the nfas
return 0 if okay dump
return 1 if screwed up
*/
int
#else
int first_node;
int last_node;
{
register int i;
nfa_node *t;
for (i=first_node; i<=last_node; ++i){
t = NFA(i);
if (!t) break;
}
return 0;
}
>>
<<
/* DLG-specific syntax error message generator
* (define USER_ZZSYN when compiling so don't get 2 definitions)
*/
void
#else
int tok;
int etok;
int k;
{
else
{
}
}
>>