Wild Life  2.29
 All Data Structures Files Functions Variables Typedefs Macros
Macros | Functions | Variables
token.c File Reference

Go to the source code of this file.

Macros

#define isoctal(c)   (c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7')
 

Functions

void TOKEN_ERROR (ptr_psi_term p)
 
void stdin_cleareof ()
 
void heap_add_int_attr (ptr_psi_term t, char *attrname, long value)
 
void stack_add_int_attr (ptr_psi_term t, char *attrname, long value)
 
void heap_mod_int_attr (ptr_psi_term t, char *attrname, long value)
 
void heap_add_str_attr (ptr_psi_term t, char *attrname, char *str)
 
void stack_add_str_attr (ptr_psi_term t, char *attrname, char *str)
 
void heap_mod_str_attr (ptr_psi_term t, char *attrname, char *str)
 
void heap_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 
void stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 
void bk_stack_add_psi_attr (ptr_psi_term t, char *attrname, ptr_psi_term g)
 
GENERIC get_attr (ptr_psi_term t, char *attrname)
 
FILE * get_stream (ptr_psi_term t)
 
void save_state (ptr_psi_term t)
 
void restore_state (ptr_psi_term t)
 
void new_state (ptr_psi_term *t)
 
void save_parse_state (ptr_parse_block pb)
 
void restore_parse_state (ptr_parse_block pb)
 
void init_parse_state ()
 
void begin_terminal_io ()
 
void end_terminal_io ()
 
char * expand_file_name (char *s)
 
long open_input_file (char *file)
 
long open_output_file (string file)
 
long read_char ()
 
void put_back_char (long c)
 
void put_back_token (psi_term t)
 
void psi_term_error ()
 
void read_comment (ptr_psi_term tok)
 
void read_string_error (int n)
 
int base2int (int n)
 
void read_string (ptr_psi_term tok, long e)
 
long symbolic (long c)
 
long legal_in_name (long c)
 
void read_name (ptr_psi_term tok, long ch, long(*f)(long), ptr_definition typ)
 
void read_number (ptr_psi_term tok, long c)
 
void read_token_main (ptr_psi_term, long)
 
void read_token (ptr_psi_term tok)
 
void read_token_b (ptr_psi_term tok)
 

Variables

long trace_input =FALSE
 
static long inchange
 
static long outchange
 
static FILE * out
 
ptr_psi_term old_state =NULL
 

Macro Definition Documentation

#define isoctal (   c)    (c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7')

Definition at line 737 of file token.c.

Function Documentation

int base2int ( int  n)

Definition at line 705 of file token.c.

707 {
708  switch (n) {
709  case '0': return 0;
710  case '1': return 1;
711  case '2': return 2;
712  case '3': return 3;
713  case '4': return 4;
714  case '5': return 5;
715  case '6': return 6;
716  case '7': return 7;
717  case '8': return 8;
718  case '9': return 9;
719  case 'a':
720  case 'A': return 10;
721  case 'b':
722  case 'B': return 11;
723  case 'c':
724  case 'C': return 12;
725  case 'd':
726  case 'D': return 13;
727  case 'e':
728  case 'E': return 14;
729  case 'f':
730  case 'F': return 15;
731  default:
732  fprintf(stderr,"base2int('%c'): illegal argument\n",n);
733  exit(EXIT_FAILURE);
734  }
735 }
void begin_terminal_io ( )

Definition at line 410 of file token.c.

References inchange, input_state, input_stream, open_input_file(), out, outchange, and output_stream.

411 {
412  inchange = (input_stream!=stdin);
413  outchange = (output_stream!=stdout);
414 
415  if (outchange) {
417  output_stream=stdout;
418  }
419 
420  if (inchange) {
422  (void)open_input_file("stdin");
423  }
424 }
ptr_psi_term input_state
Definition: def_glob.h:199
ptr_psi_term old_state
Definition: token.c:399
static long outchange
Definition: token.c:397
FILE * input_stream
Definition: def_glob.h:38
static long inchange
Definition: token.c:397
static FILE * out
Definition: token.c:398
FILE * output_stream
Definition: def_glob.h:41
long open_input_file(char *file)
Definition: token.c:504
void bk_stack_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

Definition at line 200 of file token.c.

References bk_stack_insert(), FEATCMP, and heap_copy_string().

204 {
205  (void)bk_stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list), (GENERIC)g);
206 }
#define FEATCMP
Definition: def_const.h:257
ptr_node bk_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:309
char * heap_copy_string(char *s)
Definition: trees.c:147
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void end_terminal_io ( )

Definition at line 431 of file token.c.

References inchange, input_state, NULL, old_state, out, outchange, output_stream, and restore_state().

432 {
433  if (inchange) {
436  old_state=NULL; /* RM: Feb 17 1993 */
437  }
438  if (outchange)
440 }
#define NULL
Definition: def_const.h:203
ptr_psi_term input_state
Definition: def_glob.h:199
ptr_psi_term old_state
Definition: token.c:399
static long outchange
Definition: token.c:397
void restore_state(ptr_psi_term t)
Definition: token.c:267
static long inchange
Definition: token.c:397
static FILE * out
Definition: token.c:398
FILE * output_stream
Definition: def_glob.h:41
char* expand_file_name ( char *  s)

Definition at line 449 of file token.c.

References STRLEN.

451 {
452  char *r;
453  char *home; // *getenv();
454  struct passwd *pw;
455  /* char *user="eight character name"; 18.5 */
456  char userbuf[STRLEN];
457  char *user=userbuf;
458  char *t1,*t2;
459 
460  r=s;
461  if (s[0]=='~') {
462  t1=s+1;
463  t2=user;
464  while (*t1!=0 && *t1!='/') {
465  *t2= *t1;
466  *t2++;
467  *t1++;
468  }
469  *t2=0;
470  if ((int)strlen(user)>0) {
471  pw = getpwnam(user);
472  if (pw) {
473  user=pw->pw_dir;
474  r=(char *)malloc(strlen(user)+strlen(t1)+1);
475  sprintf(r,"%s%s",user,t1);
476  }
477  else
478  /* if (warning()) printf("couldn't find user '%s'.\n",user) */;
479  }
480  else {
481  home=getenv("HOME");
482  if (home) {
483  r=(char *)malloc(strlen(home)+strlen(s)+1);
484  sprintf(r,"%s%s",home,s+1);
485  }
486  else
487  /* if (warning()) printf("no HOME directory.\n") */;
488  }
489  }
490 
491  /* printf("*** Using file name: '%s'\n",r); */
492 
493  return r;
494 }
#define STRLEN
Definition: def_const.h:86
GENERIC get_attr ( ptr_psi_term  t,
char *  attrname 
)

Definition at line 210 of file token.c.

References wl_node::data, FEATCMP, and find().

213 {
214  ptr_node n=find(FEATCMP,attrname,t->attr_list);
215  return n->data;
216 }
#define FEATCMP
Definition: def_const.h:257
GENERIC data
Definition: def_struct.h:185
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
ptr_node attr_list
Definition: def_struct.h:171
FILE* get_stream ( ptr_psi_term  t)

Definition at line 219 of file token.c.

References get_attr(), and STREAM.

221 {
222  return (FILE *) ((ptr_psi_term)get_attr(t,STREAM))->value_3;
223 }
#define STREAM
Definition: def_const.h:225
GENERIC get_attr(ptr_psi_term t, char *attrname)
Definition: token.c:210
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
void heap_add_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

Definition at line 58 of file token.c.

References FEATCMP, heap_alloc(), heap_copy_string(), heap_insert(), heap_psi_term(), integer, REAL, wl_psi_term::type, and wl_psi_term::value_3.

62 {
63  ptr_psi_term t1;
64 
65  t1=heap_psi_term(4);
66  t1->type=integer;
67  t1->value_3=heap_alloc(sizeof(REAL));
68  *(REAL *)t1->value_3 = (REAL) value;
69 
70  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list), (GENERIC)t1);
71 }
#define FEATCMP
Definition: def_const.h:257
ptr_psi_term heap_psi_term(long stat)
Definition: lefun.c:63
#define REAL
Definition: def_const.h:72
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_definition integer
Definition: def_glob.h:93
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void heap_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

Definition at line 184 of file token.c.

References FEATCMP, heap_copy_string(), and heap_insert().

188 {
189  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) g);
190 }
#define FEATCMP
Definition: def_const.h:257
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
char * heap_copy_string(char *s)
Definition: trees.c:147
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void heap_add_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

Definition at line 122 of file token.c.

References FEATCMP, heap_copy_string(), heap_insert(), heap_psi_term(), quoted_string, wl_psi_term::type, and wl_psi_term::value_3.

126 {
127  ptr_psi_term t1;
128 
129  t1=heap_psi_term(4);
130  t1->type=quoted_string;
131  t1->value_3=(GENERIC)heap_copy_string(str);
132 
133  (void)heap_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
134 }
#define FEATCMP
Definition: def_const.h:257
ptr_psi_term heap_psi_term(long stat)
Definition: lefun.c:63
ptr_node heap_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:276
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_definition quoted_string
Definition: def_glob.h:101
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void heap_mod_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

Definition at line 91 of file token.c.

References wl_node::data, FEATCMP, find(), REAL, and wl_psi_term::value_3.

95 {
96  ptr_node n;
97  ptr_psi_term t1;
98 
99  n=find(FEATCMP,attrname,t->attr_list);
100  t1=(ptr_psi_term)n->data;
101  *(REAL *)t1->value_3 = (REAL) value;
102 }
#define FEATCMP
Definition: def_const.h:257
GENERIC data
Definition: def_struct.h:185
#define REAL
Definition: def_const.h:72
GENERIC value_3
Definition: def_struct.h:170
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_node attr_list
Definition: def_struct.h:171
void heap_mod_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

Definition at line 153 of file token.c.

References wl_node::data, FEATCMP, find(), heap_copy_string(), and wl_psi_term::value_3.

157 {
158  ptr_node n;
159  ptr_psi_term t1;
160 
161  n=find(FEATCMP,attrname,t->attr_list);
162  t1=(ptr_psi_term)n->data;
163  t1->value_3=(GENERIC)heap_copy_string(str);
164 }
#define FEATCMP
Definition: def_const.h:257
GENERIC data
Definition: def_struct.h:185
char * heap_copy_string(char *s)
Definition: trees.c:147
GENERIC value_3
Definition: def_struct.h:170
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void init_parse_state ( )

Definition at line 381 of file token.c.

References eof_flag, FALSE, line_count, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stringparse, and TRUE.

382 {
383  line_count=0;
385  saved_char=0;
386  old_saved_char=0;
389  eof_flag=FALSE;
391 }
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
long old_saved_char
Definition: def_glob.h:193
#define NULL
Definition: def_const.h:203
long saved_char
Definition: def_glob.h:192
long line_count
Definition: def_glob.h:39
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
long stringparse
Definition: def_glob.h:202
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
long legal_in_name ( long  c)

Definition at line 861 of file token.c.

References DIGIT, LOWER, and UPPER.

863 {
864  return
865  UPPER(c) ||
866  LOWER(c) ||
867  DIGIT(c);
868 
869  /* || c=='\'' RM: Dec 16 1992 */ ;
870 }
#define UPPER(C)
Definition: def_macro.h:39
#define DIGIT(C)
Definition: def_macro.h:37
#define LOWER(C)
Definition: def_macro.h:41
void new_state ( ptr_psi_term t)

Definition at line 301 of file token.c.

References current_module, CURRENT_MODULE, eof_flag, EOF_FLAG, heap_add_int_attr(), heap_add_psi_attr(), heap_add_str_attr(), heap_psi_term(), input_file_name, INPUT_FILE_NAME, input_stream, inputfilesym, lf_false, lf_true, line_count, LINE_COUNT, wl_module::module_name, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, stream, STREAM, wl_psi_term::type, and wl_psi_term::value_3.

303 {
304  ptr_psi_term t1;
305 
306  *t=heap_psi_term(4);
307  (*t)->type=inputfilesym;
308 
309  t1=heap_psi_term(4);
310  t1->type=stream;
312  heap_add_psi_attr(*t,STREAM,t1);
313 
314  /* RM: Jan 27 1993 */
316 
317  /*
318  printf("Creating new state for file '%s', module '%s'\n",
319  input_file_name,
320  current_module->module_name);
321  */
322 
327 
330 
333 
334  t1=heap_psi_term(4);
337 
338  t1=heap_psi_term(4);
341 }
#define LINE_COUNT
Definition: def_const.h:227
ptr_module current_module
Definition: def_glob.h:161
long eof_flag
Definition: def_glob.h:196
ptr_definition stream
Definition: def_glob.h:103
long start_of_line
Definition: def_glob.h:191
string input_file_name
Definition: def_glob.h:40
#define SAVED_PSI_TERM
Definition: def_const.h:231
ptr_psi_term heap_psi_term(long stat)
Definition: lefun.c:63
#define OLD_SAVED_CHAR
Definition: def_const.h:230
ptr_psi_term null_psi_term
Definition: def_glob.h:140
#define CURRENT_MODULE
Definition: def_const.h:234
long old_saved_char
Definition: def_glob.h:193
long saved_char
Definition: def_glob.h:192
long line_count
Definition: def_glob.h:39
#define STREAM
Definition: def_const.h:225
#define START_OF_LINE
Definition: def_const.h:228
void heap_add_str_attr(ptr_psi_term t, char *attrname, char *str)
Definition: token.c:122
void heap_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
Definition: token.c:184
ptr_definition lf_true
Definition: def_glob.h:107
FILE * input_stream
Definition: def_glob.h:38
ptr_definition lf_false
Definition: def_glob.h:89
GENERIC value_3
Definition: def_struct.h:170
#define INPUT_FILE_NAME
Definition: def_const.h:226
char * module_name
Definition: def_struct.h:75
#define OLD_SAVED_PSI_TERM
Definition: def_const.h:232
void heap_add_int_attr(ptr_psi_term t, char *attrname, long value)
Definition: token.c:58
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
#define EOF_FLAG
Definition: def_const.h:233
ptr_definition type
Definition: def_struct.h:165
#define SAVED_CHAR
Definition: def_const.h:229
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_definition inputfilesym
Definition: def_glob.h:120
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
long open_input_file ( char *  file)

Definition at line 504 of file token.c.

References Errorline(), expand_file_name(), FALSE, init_parse_state(), input_file_name, input_state, input_stream, new_state(), noisy, NULL, restore_state(), save_state(), stdin_state, and TRUE.

506 {
507  long ok=TRUE;
508  long stdin_flag;
509 
510  /* Save global input file state */
512 
513  file=expand_file_name(file);
514 
515  if ((stdin_flag=(!strcmp(file,"stdin")))) {
516  input_stream=stdin;
517  noisy=TRUE;
518  }
519  else {
520  input_stream=fopen(file,"r");
521  noisy=FALSE;
522  }
523 
524  if (input_stream==NULL) {
525  Errorline("file '%s' does not exist.\n",file);
526  file="stdin";
527  input_stream=stdin;
528  noisy=TRUE;
529  ok=FALSE;
530  }
531 
532  if (!stdin_flag || stdin_state==NULL) {
533  /* Initialize a new global input file state */
534  strcpy(input_file_name,file);
536  /* Create a new state containing the new global values */
538  if (stdin_flag) stdin_state=input_state;
539  }
540  else {
543  }
544 
545  return ok;
546 }
void init_parse_state()
Definition: token.c:381
ptr_psi_term stdin_state
Definition: def_glob.h:200
string input_file_name
Definition: def_glob.h:40
void save_state(ptr_psi_term t)
Definition: token.c:230
#define NULL
Definition: def_const.h:203
ptr_psi_term input_state
Definition: def_glob.h:199
long noisy
Definition: def_glob.h:35
void Errorline(char *format,...)
Definition: error.c:414
void restore_state(ptr_psi_term t)
Definition: token.c:267
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
FILE * input_stream
Definition: def_glob.h:38
char * expand_file_name(char *s)
Definition: token.c:449
void new_state(ptr_psi_term *t)
Definition: token.c:301
long open_output_file ( string  file)

Definition at line 554 of file token.c.

References Errorline(), expand_file_name(), FALSE, NULL, output_stream, and TRUE.

556 {
557  long ok=TRUE;
558 
559 
560  file=expand_file_name(file);
561 
562  if (!strcmp(file,"stdout"))
563  output_stream=stdout;
564  else
565  if (!strcmp(file,"stderr"))
566  output_stream=stderr;
567  else
568  output_stream=fopen(file,"w");
569 
570  if (output_stream==NULL) {
571  Errorline("file '%s' could not be opened for output.\n",file);
572  ok=FALSE;
573  output_stream=stdout;
574  }
575 
576  return ok;
577 }
#define NULL
Definition: def_const.h:203
void Errorline(char *format,...)
Definition: error.c:414
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
char * expand_file_name(char *s)
Definition: token.c:449
FILE * output_stream
Definition: def_glob.h:41
void psi_term_error ( )

Definition at line 661 of file token.c.

References FALSE, input_file_name, parse_ok, perr_i(), perr_s(), and psi_term_line_number.

662 {
663  perr_i("near line %ld",psi_term_line_number);
664  if (strcmp(input_file_name,"stdin")) {
665  perr_s(" in file \042%s\042",input_file_name);
666  }
667  /* prompt="error>"; 20.8 */
668  parse_ok=FALSE;
669 }
long psi_term_line_number
Definition: def_glob.h:268
string input_file_name
Definition: def_glob.h:40
void perr_s(char *s1, char *s2)
Definition: error.c:665
#define FALSE
Definition: def_const.h:128
long parse_ok
Definition: def_glob.h:171
void perr_i(char *str, long i)
Definition: error.c:677
void put_back_char ( long  c)

Definition at line 633 of file token.c.

References Errorline(), old_saved_char, and saved_char.

635 {
636  if (old_saved_char)
637  Errorline("in tokenizer, put_back_char three times (last=%d).\n",c);
639  saved_char=c;
640 }
long old_saved_char
Definition: def_glob.h:193
long saved_char
Definition: def_glob.h:192
void Errorline(char *format,...)
Definition: error.c:414
void put_back_token ( psi_term  t)

Definition at line 647 of file token.c.

References Errorline(), NULL, old_saved_psi_term, saved_psi_term, and stack_copy_psi_term().

649 {
651  Errorline("in parser, put_back_token three times (last=%P).\n",t);
654 }
#define NULL
Definition: def_const.h:203
void Errorline(char *format,...)
Definition: error.c:414
ptr_psi_term stack_copy_psi_term(psi_term t)
Definition: parser.c:183
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
long read_char ( )

Definition at line 587 of file token.c.

References EOLN, FALSE, infoline(), input_stream, line_count, NULL, old_saved_char, prompt, saved_char, start_of_line, stringinput, stringparse, trace_input, and TRUE.

588 {
589  int c=0;
590 
591  if ((c=saved_char)) {
593  old_saved_char=0;
594  }
595  else if (stringparse) {
596  if ((c=(*stringinput)))
597  stringinput++;
598  else
599  c=EOF;
600  }
601  else if (input_stream == NULL || feof(input_stream))
602  c=EOF;
603  else {
604  if (start_of_line) {
606  line_count++;
607  if (input_stream==stdin) infoline("%s",prompt); /* 21.1 */
608  }
609 
610  c=fgetc(input_stream);
611 
612  if(trace_input) /* RM: Jan 13 1993 */
613  if(c!=EOF)
614  printf("%c",c);
615  else
616  printf(" <EOF>\n");
617 
618  if (c==EOLN)
620  }
621 
622  /* printf("%c\n",c); RM: Jan 5 1993 Just to trace the parser */
623 
624  return c;
625 }
long start_of_line
Definition: def_glob.h:191
long old_saved_char
Definition: def_glob.h:193
#define NULL
Definition: def_const.h:203
long saved_char
Definition: def_glob.h:192
long trace_input
Definition: token.c:8
long line_count
Definition: def_glob.h:39
#define EOLN
Definition: def_const.h:140
void infoline(char *format,...)
Definition: error.c:245
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
FILE * input_stream
Definition: def_glob.h:38
char * prompt
Definition: def_glob.h:42
long stringparse
Definition: def_glob.h:202
char * stringinput
Definition: def_glob.h:203
void read_comment ( ptr_psi_term  tok)

Definition at line 676 of file token.c.

References comment, EOLN, and read_char().

678 {
679  long c;
680 
681  do {
682  c=read_char();
683  } while (c!=EOF && c!=EOLN);
684 
685  tok->type=comment;
686 }
ptr_definition comment
Definition: def_glob.h:80
#define EOLN
Definition: def_const.h:140
ptr_definition type
Definition: def_struct.h:165
long read_char()
Definition: token.c:587
void read_name ( ptr_psi_term  tok,
long  ch,
long (*)(long)  f,
ptr_definition  typ 
)

Definition at line 878 of file token.c.

References bk2_stack_insert(), constant, create_module(), FALSE, find(), global, heap_copy_string(), legal_in_name(), wl_module::module_name, NULL, put_back_char(), read_char(), STRCMP, STRLEN, SYMBOL, symbolic(), TOKEN_ERROR(), TRUE, update_symbol(), var_occurred, var_tree, and warningline().

883 {
884  char c;
885  string str;
886  long len=1;
887  long store=TRUE;
888  long flag=TRUE;
889  ptr_module module=NULL;
890  ptr_node n; /* RM: Feb 9 1993 */
891 
892  tok->coref=NULL;
893  tok->resid=NULL;
894  tok->attr_list=NULL;
895 
896  str[0]=ch;
897 
898  do {
899  c=read_char();
900  flag=(*f)(c);
901 
902  if(c=='#' && /* RM: Feb 3 1993 */
903  (long)f==(long)legal_in_name &&
904  len>0 &&
905  len<STRLEN &&
906  !module) {
907  str[len]=0;
908  module=create_module(str);
909  len=0;
910  flag=TRUE;
911 
912  /* RM: Sep 21 1993 */
913  /* Change the type function if required */
914  c=read_char();
915  if SYMBOL(c)
916  f=symbolic;
917  put_back_char(c);
918  }
919  else
920  if (flag) {
921  if (store)
922  if (len==STRLEN) {
923  warningline("name too long, extra ignored (%E).\n");
924  store=FALSE;
925  }
926  else
927  str[len++]=c;
928  }
929  else
930  put_back_char(c);
931  } while(flag);
932 
933  if(module && len==0) { /* RM: Feb 3 1993 */
934  strcpy(str,module->module_name);
935  len=strlen(str);
936  put_back_char('#');
937  module=NULL;
938  }
939 
940  str[len]=0;
941 
942  tok->type=typ;
943 
944  if(typ==constant) {
945  /* printf("module=%s\n",module->module_name); */
946  tok->type=update_symbol(module,str); /* RM: Feb 3 1993 */
947  tok->value_3=NULL;
948 
949  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
950 
951  /* PVR 4.2.94 for correct level incrementing */
952  if (tok->type->type_def==(def_type)global) {
954  }
955  if (FALSE /*tok->type->type==global && tok->type->global_value*/) {
956  /* RM: Nov 10 1993 */
957 
958  /* Remove this for Bruno who didn't like it, and doesn't like
959  to use "print_depth" */
960 
961  /* RM: Feb 9 1993 */
962  /* Add into the variable tree */
965  if (n==NULL) {
966  /* The change is always trailed. */
967  (void)bk2_stack_insert(STRCMP,
968  tok->type->keyword->symbol,
969  &var_tree,
970  (GENERIC)tok->type->global_value);
971  }
972  }
973 
974  }
975  else
976  tok->value_3=(GENERIC)heap_copy_string(str);
977 }
ptr_residuation resid
Definition: def_struct.h:173
ptr_module create_module(char *module)
Definition: modules.c:67
#define global
Definition: def_const.h:364
def_type type_def
Definition: def_struct.h:133
ptr_definition constant
Definition: def_glob.h:82
ptr_keyword keyword
Definition: def_struct.h:124
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
ptr_node bk2_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:327
char * symbol
Definition: def_struct.h:91
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
#define SYMBOL(C)
Definition: def_macro.h:52
char * heap_copy_string(char *s)
Definition: trees.c:147
#define TRUE
Definition: def_const.h:127
#define STRCMP
Definition: def_const.h:255
ptr_psi_term global_value
Definition: def_struct.h:141
#define FALSE
Definition: def_const.h:128
long var_occurred
Definition: def_glob.h:189
GENERIC value_3
Definition: def_struct.h:170
char * module_name
Definition: def_struct.h:75
ptr_psi_term coref
Definition: def_struct.h:172
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
long legal_in_name(long c)
Definition: token.c:861
long symbolic(long c)
Definition: token.c:850
#define STRLEN
Definition: def_const.h:86
void TOKEN_ERROR(ptr_psi_term p)
Definition: token.c:30
void warningline(char *format,...)
Definition: error.c:327
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
long read_char()
Definition: token.c:587
ptr_node attr_list
Definition: def_struct.h:171
void put_back_char(long c)
Definition: token.c:633
void read_number ( ptr_psi_term  tok,
long  c 
)

Definition at line 986 of file token.c.

References DIGIT, heap_alloc(), integer, put_back_char(), read_char(), REAL, and real.

989 {
990  long c2;
991  REAL f,p;
992  long /* sgn, */ pwr,posflag;
993 
994  /* if (sgn=(c=='-')) c=read_char(); */
995 
996  /* tok->type=integer; RM: Mar 8 1993 */
997 
998  f=0.0;
999  do { f=f*10.0+(c-'0'); c=read_char(); } while (DIGIT(c));
1000 
1001  if (c=='.') {
1002  c2=read_char();
1003  if DIGIT(c2) {
1004  /* tok->type=real; RM: Mar 8 1993 */
1005  p=10.0;
1006  while (DIGIT(c2)) { f=f+(c2-'0')/p; p=p*10.0; c2=read_char(); }
1007  put_back_char(c2);
1008  }
1009  else {
1010  put_back_char(c2);
1011  put_back_char(c);
1012  }
1013  }
1014  else
1015  put_back_char(c);
1016 
1017  c=read_char();
1018  if (c=='e' || c=='E') {
1019  c2=read_char();
1020  if (c2=='+' || c2=='-' || DIGIT(c2)) {
1021  tok->type=real;
1022  posflag = (c2=='+' || DIGIT(c2));
1023  if (!DIGIT(c2)) c2=read_char();
1024  pwr=0;
1025  while (DIGIT(c2)) { pwr=pwr*10+(c2-'0'); c2=read_char(); }
1026  put_back_char(c2);
1027  p=1.0;
1028  while (pwr>=100) { pwr-=100; if (posflag) p*=1e100; else p/=1e100; }
1029  while (pwr>=10 ) { pwr-=10; if (posflag) p*=1e10; else p/=1e10; }
1030  while (pwr>0 ) { pwr-=1; if (posflag) p*=1e1; else p/=1e1; }
1031  f*=p;
1032  }
1033  else {
1034  put_back_char(c2);
1035  put_back_char(c);
1036  }
1037  }
1038  else
1039  put_back_char(c);
1040 
1041  /* if (sgn) f = -f; */
1042  tok->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
1043  *(REAL *)tok->value_3=f;
1044 
1045  /* RM: Mar 8 1993 */
1046  if(f==floor(f))
1047  tok->type=integer;
1048  else
1049  tok->type=real;
1050 }
#define DIGIT(C)
Definition: def_macro.h:37
#define REAL
Definition: def_const.h:72
ptr_definition real
Definition: def_glob.h:102
ptr_definition integer
Definition: def_glob.h:93
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
long read_char()
Definition: token.c:587
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void put_back_char(long c)
Definition: token.c:633
void read_string ( ptr_psi_term  tok,
long  e 
)

Definition at line 743 of file token.c.

References base2int(), FALSE, heap_copy_string(), isoctal, NULL, put_back_char(), read_char(), read_string_error(), STRLEN, TOKEN_ERROR(), TRUE, update_symbol(), and warningline().

746 {
747  long c;
748  string str;
749  long len=0;
750  long store=TRUE;
751  long flag=TRUE;
752 
753  str[len]=0;
754 
755  do {
756  c=read_char();
757  if (c==EOF) {
758  store=FALSE;
759  flag=FALSE;
761  }
762  else if (e=='"' && c=='\\') {
763  c=read_char();
764  if (c==EOF) {
765  store=FALSE;
766  flag=FALSE;
767  put_back_char('\\');
769  }
770  else {
771  switch (c) {
772  case 'a': c='\a'; break;
773  case 'b': c='\b'; break;
774  case 'f': c='\f'; break;
775  case 'n': c='\n'; break;
776  case 'r': c='\r'; break;
777  case 't': c='\t'; break;
778  case 'v': c='\v'; break;
779  /* missing \ooo and \xhh */
780  case 'x':
781  {
782  int n;
783  c=read_char();
784  if (c==EOF) {
785  store=flag=FALSE;
787  break;
788  }
789  else if (!isxdigit(c)) {
790  store=flag=FALSE;
792  break;
793  }
794  else {
795  n = base2int(c);
796  }
797  c=read_char();
798  if (isxdigit(c)) n = 16*n+base2int(c);
799  else put_back_char(c);
800  c=n;
801  break;
802  }
803  default:
804  if (isoctal(c)) {
805  int n,i;
806  for(i=n=0;i<3&&isoctal(c);i++,c=read_char())
807  n = n*8 + base2int(c);
808  if (c!=EOF) put_back_char(c);
809  c=n;
810  break;
811  }
812  else break;
813  }
814  }
815  }
816  else
817  if (c==e) {
818  c=read_char();
819  if (c!=e) {
820  store=FALSE;
821  flag=FALSE;
822  put_back_char(c);
823  }
824  }
825  if (store)
826  if (len==STRLEN) {
827  warningline("string too long, extra ignored (%E).\n");
828  store=FALSE;
829  }
830  else {
831  str[len++]=c;
832  str[len]=0;
833  }
834  } while(flag);
835 
836  if (e=='"')
837  tok->value_3=(GENERIC)heap_copy_string(str);
838  else {
839  tok->type=update_symbol(NULL,str); /* Maybe no_module would be better */
840  tok->value_3=NULL;
841  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
842  }
843 }
int base2int(int n)
Definition: token.c:705
#define NULL
Definition: def_const.h:203
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
void read_string_error(int n)
Definition: token.c:689
char * heap_copy_string(char *s)
Definition: trees.c:147
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
GENERIC value_3
Definition: def_struct.h:170
#define isoctal(c)
Definition: token.c:737
#define STRLEN
Definition: def_const.h:86
void TOKEN_ERROR(ptr_psi_term p)
Definition: token.c:30
void warningline(char *format,...)
Definition: error.c:327
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
long read_char()
Definition: token.c:587
void put_back_char(long c)
Definition: token.c:633
void read_string_error ( int  n)

Definition at line 689 of file token.c.

References FALSE, parse_ok, stringparse, and Syntaxerrorline().

691 {
693  else
694  switch (n) {
695  case 0:
696  Syntaxerrorline("end of file reached before end of string (%E).\n");
697  break;
698  case 1:
699  Syntaxerrorline("Hexadecimal digit expected (%E).\n");
700  break;
701  }
702 }
void Syntaxerrorline(char *format,...)
Definition: error.c:498
#define FALSE
Definition: def_const.h:128
long stringparse
Definition: def_glob.h:202
long parse_ok
Definition: def_glob.h:171
void read_token ( ptr_psi_term  tok)

Definition at line 1063 of file token.c.

References read_token_main(), and TRUE.

1065 { read_token_main(tok, TRUE); }
void read_token_main(ptr_psi_term, long)
Definition: token.c:1073
#define TRUE
Definition: def_const.h:127
void read_token_b ( ptr_psi_term  tok)

Definition at line 1069 of file token.c.

References FALSE, and read_token_main().

1071 { read_token_main(tok, FALSE); }
void read_token_main(ptr_psi_term, long)
Definition: token.c:1073
#define FALSE
Definition: def_const.h:128
void read_token_main ( ptr_psi_term  tok,
long  for_parser 
)

Definition at line 1073 of file token.c.

References bk2_stack_insert(), choice_stack, comment, constant, wl_psi_term::coref, current_module, cut, wl_node::data, DIGIT, eof, EOLN, Errorline(), FALSE, final_dot, final_question, find(), legal_in_name(), line_count, LOWER, nothing, NULL, old_saved_psi_term, prompt, psi_term_line_number, put_back_char(), quoted_string, read_char(), read_comment(), read_name(), read_number(), read_string(), read_token(), saved_psi_term, SINGLE, stack_psi_term(), STRCMP, SYMBOL, symbolic(), TOKEN_ERROR(), TRUE, update_symbol(), UPPER, var_occurred, var_tree, and variable.

1076 {
1077  long c, c2;
1078  ptr_node n;
1079  char p[2];
1080 
1081  if (for_parser && (saved_psi_term!=NULL)) {
1082  *tok= *saved_psi_term;
1085  }
1086  else {
1087  tok->type=nothing;
1088 
1089  do {
1090  c=read_char();
1091  } while(c!=EOF && (c<=32));
1092 
1093  if (for_parser) psi_term_line_number=line_count;
1094 
1095  switch(c) {
1096  case EOF:
1097  tok->type=eof;
1098  tok->value_3=NULL;
1099  break;
1100  case '%':
1101  read_comment(tok);
1102  break;
1103  case '"':
1104  read_string(tok,c);
1105  tok->type=quoted_string;
1106  break;
1107  case 39: /* The quote symbol "'" */
1108  read_string(tok,c);
1109  break;
1110 
1111  default:
1112 
1113  /* Adding this results in problems with terms like (N-1) */
1114  /* if (c=='-' && (c2=read_char()) && DIGIT(c2)) {
1115  put_back_char(c2);
1116  read_number(tok,c);
1117  }
1118  else */
1119 
1120  if(c=='.' || c=='?') { /* RM: Jul 7 1993 */
1121  c2=read_char();
1122  put_back_char(c2);
1123  /*printf("c2=%d\n",c2);*/
1124  if(c2<=' ' || c2==EOF) {
1125  if(c=='.')
1126  tok->type=final_dot;
1127  else
1128  tok->type=final_question;
1129 
1130  tok->value_3=NULL;
1131  }
1132  else
1133  read_name(tok,c,symbolic,constant);
1134  }
1135  else
1136  if DIGIT(c)
1137  read_number(tok,c);
1138  else
1139  if UPPER(c) {
1141  }
1142  else
1143  if LOWER(c) {
1145  }
1146  else
1147  if SYMBOL(c) {
1148  read_name(tok,c,symbolic,constant);
1149  }
1150  else /* RM: Jul 7 1993 Moved this */
1151  if SINGLE(c) {
1152  p[0]=c; p[1]=0;
1154  tok->value_3=NULL;
1155  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
1156  }
1157  else {
1158  Errorline("illegal character %d in input (%E).\n",c);
1159  }
1160  }
1161 
1162  if (tok->type==variable) {
1163  if (tok->value_3) {
1164  /* If the variable read in has name "_", then it becomes 'top' */
1165  /* and is no longer a variable whose name must be remembered. */
1166  /* As a result, '@' and '_' are synonyms in the program input. */
1167  if (!strcmp((char *)tok->value_3,"_")) {
1168  p[0]='@'; p[1]=0;
1170  tok->value_3=NULL;
1171  TOKEN_ERROR(tok); /* RM: Feb 1 1993 */
1172  }
1173  else {
1174  /* Insert into variable tree, create 'top' value if need be. */
1176  n=find(STRCMP,(char *)tok->value_3,var_tree);
1177  if (n==NULL) {
1179  /* The change is always trailed. */
1180  (void)bk2_stack_insert(STRCMP,(char *)tok->value_3,&var_tree,(GENERIC)t); /* 17.8 */
1181  tok->coref=t;
1182  }
1183  else
1184  tok->coref=(ptr_psi_term)n->data;
1185  }
1186  }
1187  /* else do nothing */
1188  }
1189  }
1190 
1191  if (tok->type==comment)
1192  read_token(tok);
1193 
1194  if (tok->type!=variable)
1195  tok->coref=NULL;
1196 
1197  tok->attr_list=NULL;
1198  tok->status=0;
1199  tok->flags=FALSE; /* 14.9 */
1200  tok->resid=NULL;
1201 
1202  if (tok->type==cut) /* 12.7 */
1204 
1205  do {
1206  c=read_char();
1207  if (c==EOLN) {
1208  if (for_parser) put_back_char(c);
1209  c=0;
1210  }
1211  else if (c<0 || c>32) {
1212  put_back_char(c);
1213  c=0;
1214  }
1215  } while(c && c!=EOF);
1216 
1217  if (for_parser) prompt="| ";
1218 }
ptr_residuation resid
Definition: def_struct.h:173
ptr_module current_module
Definition: def_glob.h:161
#define UPPER(C)
Definition: def_macro.h:39
ptr_definition comment
Definition: def_glob.h:80
long psi_term_line_number
Definition: def_glob.h:268
#define DIGIT(C)
Definition: def_macro.h:37
ptr_definition constant
Definition: def_glob.h:82
GENERIC data
Definition: def_struct.h:185
#define NULL
Definition: def_const.h:203
ptr_node var_tree
Definition: def_glob.h:26
ptr_node bk2_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:327
void read_name(ptr_psi_term tok, long ch, long(*f)(long), ptr_definition typ)
Definition: token.c:878
void read_string(ptr_psi_term tok, long e)
Definition: token.c:743
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
#define LOWER(C)
Definition: def_macro.h:41
#define SYMBOL(C)
Definition: def_macro.h:52
long line_count
Definition: def_glob.h:39
void Errorline(char *format,...)
Definition: error.c:414
#define EOLN
Definition: def_const.h:140
void read_number(ptr_psi_term tok, long c)
Definition: token.c:986
ptr_definition eof
Definition: def_glob.h:86
#define TRUE
Definition: def_const.h:127
#define STRCMP
Definition: def_const.h:255
ptr_definition final_dot
Definition: def_glob.h:137
#define FALSE
Definition: def_const.h:128
long var_occurred
Definition: def_glob.h:189
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term coref
Definition: def_struct.h:172
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
long legal_in_name(long c)
Definition: token.c:861
ptr_definition final_question
Definition: def_glob.h:138
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
void read_comment(ptr_psi_term tok)
Definition: token.c:676
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
char * prompt
Definition: def_glob.h:42
long symbolic(long c)
Definition: token.c:850
ptr_definition cut
Definition: def_glob.h:83
#define SINGLE(C)
Definition: def_macro.h:47
ptr_definition nothing
Definition: def_glob.h:98
void TOKEN_ERROR(ptr_psi_term p)
Definition: token.c:30
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
long read_char()
Definition: token.c:587
ptr_definition variable
Definition: def_glob.h:111
ptr_node attr_list
Definition: def_struct.h:171
ptr_choice_point choice_stack
Definition: def_glob.h:51
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
void read_token(ptr_psi_term tok)
Definition: token.c:1063
void put_back_char(long c)
Definition: token.c:633
void restore_parse_state ( ptr_parse_block  pb)

Definition at line 365 of file token.c.

References eof_flag, line_count, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, and start_of_line.

367 {
368  if (pb) {
369  line_count = pb->lc;
370  start_of_line = pb->sol;
371  saved_char = pb->sc;
372  old_saved_char = pb->osc;
373  saved_psi_term = pb->spt;
374  old_saved_psi_term = pb->ospt;
375  eof_flag = pb->ef;
376  }
377 }
ptr_psi_term ospt
Definition: def_struct.h:377
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
long old_saved_char
Definition: def_glob.h:193
long saved_char
Definition: def_glob.h:192
long line_count
Definition: def_glob.h:39
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
ptr_psi_term spt
Definition: def_struct.h:376
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
void restore_state ( ptr_psi_term  t)

Definition at line 267 of file token.c.

References eof_flag, EOF_FLAG, get_attr(), input_file_name, INPUT_FILE_NAME, input_stream, lf_true, line_count, LINE_COUNT, NULL, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, REAL, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, and STREAM.

269 {
270  // long i;
271  char *str;
272 
273 
274  input_stream = (FILE *) ((ptr_psi_term)get_attr(t,STREAM))->value_3;
275  str = (char*) ((ptr_psi_term)get_attr(t,INPUT_FILE_NAME))->value_3;
276  strcpy(input_file_name,str);
277  /* for (i=0;i++;i<=strlen(str)) input_file_name[i]=str[i]; */
278  line_count = *(REAL *) ((ptr_psi_term)get_attr(t,LINE_COUNT))->value_3;
279  saved_char = *(REAL *) ((ptr_psi_term)get_attr(t,SAVED_CHAR))->value_3;
281 
284 
287 
290 
291 
292  /* RM: Jan 27 1993
293  set_current_module(
294  find_module(((ptr_psi_term)get_attr(input_state,
295  CURRENT_MODULE))->value_3));
296  */
297 }
#define LINE_COUNT
Definition: def_const.h:227
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
string input_file_name
Definition: def_glob.h:40
#define SAVED_PSI_TERM
Definition: def_const.h:231
#define OLD_SAVED_CHAR
Definition: def_const.h:230
ptr_psi_term null_psi_term
Definition: def_glob.h:140
long old_saved_char
Definition: def_glob.h:193
#define NULL
Definition: def_const.h:203
long saved_char
Definition: def_glob.h:192
#define REAL
Definition: def_const.h:72
long line_count
Definition: def_glob.h:39
#define STREAM
Definition: def_const.h:225
#define START_OF_LINE
Definition: def_const.h:228
ptr_definition lf_true
Definition: def_glob.h:107
FILE * input_stream
Definition: def_glob.h:38
#define INPUT_FILE_NAME
Definition: def_const.h:226
#define OLD_SAVED_PSI_TERM
Definition: def_const.h:232
GENERIC get_attr(ptr_psi_term t, char *attrname)
Definition: token.c:210
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
#define EOF_FLAG
Definition: def_const.h:233
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
#define SAVED_CHAR
Definition: def_const.h:229
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
void save_parse_state ( ptr_parse_block  pb)

Definition at line 350 of file token.c.

References eof_flag, wl_parse_block::lc, line_count, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, and start_of_line.

352 {
353  if (pb) {
354  pb->lc = line_count;
355  pb->sol = start_of_line;
356  pb->sc = saved_char;
357  pb->osc = old_saved_char;
358  pb->spt = saved_psi_term;
359  pb->ospt = old_saved_psi_term;
360  pb->ef = eof_flag;
361  }
362 }
ptr_psi_term ospt
Definition: def_struct.h:377
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
long old_saved_char
Definition: def_glob.h:193
long saved_char
Definition: def_glob.h:192
long line_count
Definition: def_glob.h:39
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
ptr_psi_term spt
Definition: def_struct.h:376
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
void save_state ( ptr_psi_term  t)

Definition at line 230 of file token.c.

References wl_node::data, eof_flag, EOF_FLAG, FEATCMP, find(), heap_add_psi_attr(), heap_mod_int_attr(), heap_mod_str_attr(), heap_psi_term(), input_file_name, INPUT_FILE_NAME, input_stream, lf_false, lf_true, line_count, LINE_COUNT, null_psi_term, old_saved_char, OLD_SAVED_CHAR, old_saved_psi_term, OLD_SAVED_PSI_TERM, saved_char, SAVED_CHAR, saved_psi_term, SAVED_PSI_TERM, start_of_line, START_OF_LINE, STREAM, wl_psi_term::type, and wl_psi_term::value_3.

232 {
233  ptr_node n;
234  ptr_psi_term t1;
235 
237  t1=(ptr_psi_term)n->data;
239 
240  /* RM: Jan 27 1993
241  heap_mod_str_attr(t,CURRENT_MODULE,current_module->module_name);
242  */
243 
248 
251 
254 
255  t1=heap_psi_term(4);
258 
259  t1=heap_psi_term(4);
262 }
#define FEATCMP
Definition: def_const.h:257
#define LINE_COUNT
Definition: def_const.h:227
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
void heap_mod_int_attr(ptr_psi_term t, char *attrname, long value)
Definition: token.c:91
string input_file_name
Definition: def_glob.h:40
#define SAVED_PSI_TERM
Definition: def_const.h:231
ptr_psi_term heap_psi_term(long stat)
Definition: lefun.c:63
#define OLD_SAVED_CHAR
Definition: def_const.h:230
ptr_psi_term null_psi_term
Definition: def_glob.h:140
GENERIC data
Definition: def_struct.h:185
long old_saved_char
Definition: def_glob.h:193
long saved_char
Definition: def_glob.h:192
long line_count
Definition: def_glob.h:39
#define STREAM
Definition: def_const.h:225
#define START_OF_LINE
Definition: def_const.h:228
void heap_add_psi_attr(ptr_psi_term t, char *attrname, ptr_psi_term g)
Definition: token.c:184
ptr_definition lf_true
Definition: def_glob.h:107
FILE * input_stream
Definition: def_glob.h:38
ptr_definition lf_false
Definition: def_glob.h:89
GENERIC value_3
Definition: def_struct.h:170
#define INPUT_FILE_NAME
Definition: def_const.h:226
#define OLD_SAVED_PSI_TERM
Definition: def_const.h:232
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
#define EOF_FLAG
Definition: def_const.h:233
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
void heap_mod_str_attr(ptr_psi_term t, char *attrname, char *str)
Definition: token.c:153
ptr_definition type
Definition: def_struct.h:165
#define SAVED_CHAR
Definition: def_const.h:229
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
void stack_add_int_attr ( ptr_psi_term  t,
char *  attrname,
long  value 
)

Definition at line 73 of file token.c.

References FEATCMP, heap_alloc(), heap_copy_string(), integer, REAL, stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

77 {
78  ptr_psi_term t1;
79 
80  t1=stack_psi_term(4);
81  t1->type=integer;
82  t1->value_3=heap_alloc(sizeof(REAL)); /* 12.5 */
83  *(REAL *)t1->value_3 = (REAL) value;
84 
85  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
86 }
#define FEATCMP
Definition: def_const.h:257
#define REAL
Definition: def_const.h:72
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
ptr_definition integer
Definition: def_glob.h:93
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void stack_add_psi_attr ( ptr_psi_term  t,
char *  attrname,
ptr_psi_term  g 
)

Definition at line 192 of file token.c.

References FEATCMP, heap_copy_string(), and stack_insert().

196 {
197  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) g);
198 }
#define FEATCMP
Definition: def_const.h:257
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void stack_add_str_attr ( ptr_psi_term  t,
char *  attrname,
char *  str 
)

Definition at line 136 of file token.c.

References FEATCMP, heap_copy_string(), quoted_string, stack_copy_string(), stack_insert(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

140 {
141  ptr_psi_term t1;
142 
143  t1=stack_psi_term(4);
144  t1->type=quoted_string;
146 
147  (void)stack_insert(FEATCMP,heap_copy_string(attrname),&(t->attr_list),(GENERIC) t1);
148 }
#define FEATCMP
Definition: def_const.h:257
char * stack_copy_string(char *s)
Definition: trees.c:155
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void stdin_cleareof ( )

Definition at line 42 of file token.c.

References eof_flag, FALSE, NULL, old_saved_char, old_saved_psi_term, saved_char, saved_psi_term, start_of_line, stdin_terminal, and TRUE.

43 {
44  if (eof_flag && stdin_terminal) {
45  clearerr(stdin);
49  saved_char=0;
52  }
53 }
long stdin_terminal
Definition: def_glob.h:188
long eof_flag
Definition: def_glob.h:196
long start_of_line
Definition: def_glob.h:191
long old_saved_char
Definition: def_glob.h:193
#define NULL
Definition: def_const.h:203
long saved_char
Definition: def_glob.h:192
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_psi_term saved_psi_term
Definition: def_glob.h:194
ptr_psi_term old_saved_psi_term
Definition: def_glob.h:195
long symbolic ( long  c)

Definition at line 850 of file token.c.

References SYMBOL.

852 {
853  return SYMBOL(c);
854 }
#define SYMBOL(C)
Definition: def_macro.h:52
void TOKEN_ERROR ( ptr_psi_term  p)

Definition at line 30 of file token.c.

References error_psi_term, Syntaxerrorline(), and wl_psi_term::type.

33 {
34  if(p->type==error_psi_term->type) {
35  Syntaxerrorline("Module violation (%E).\n");
36  }
37 }
void Syntaxerrorline(char *format,...)
Definition: error.c:498
ptr_psi_term error_psi_term
Definition: def_glob.h:23
ptr_definition type
Definition: def_struct.h:165

Variable Documentation

long inchange
static

Definition at line 397 of file token.c.

ptr_psi_term old_state =NULL

Definition at line 399 of file token.c.

FILE* out
static

Definition at line 398 of file token.c.

long outchange
static

Definition at line 397 of file token.c.

long trace_input =FALSE

Definition at line 8 of file token.c.