MISR Toolkit  1.5.1
rdvalue.c
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Routine: ReadValue
4 
5  Description: Parses an ODL value given as ASCII text and assigns it to a
6  specified parameter. The input text string may contain any
7  ODL scalar, sequence or set value. This routine is used to
8  process values entered in text format as input to label
9  editors and similar programs. To do its job, this routine
10  forms an ODL parameter assignment statement and then calls
11  the ODL parser to parse the statement and place the results
12  onto an ODL tree.
13 
14  Input:
15  node - Pointer to the aggregate node to which the
16  parameter and value are to be attached.
17  parameter_name - Character string containing the parameter name.
18  value_string - Character string containing the value in ASCII
19  text format.
20 
21  Output: A value of one is returned as the function value if parsing was
22  completed successfully; otherwise a value of zero is returned.
23 
24  Author: Randy Davis, University of Colorado LASP
25 
26  Creation Date: 09 October 1990
27  Last Modified: 18 May 1991
28 
29  History:
30 
31  Creation - This routine first appeared in Version 2.0 of the ODLC library.
32 
33  Version 2.1 - 13 March 1991 - Randy Davis, U. of Colorado LASP
34  a) Set global variable ODLlinenumber_flag to FALSE to indicate that
35  line numbers shouldn't be included in error messages generated
36  by the parser when called by this routine.
37 
38  Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
39  a) Removed include statements that were Unix specific and placed them
40  in odldef.h.
41 
42 *****************************************************************************/
43 
44 #include "odldef.h"
45 
46 /* The following statements duplicate two lexical analyzer constants for
47  use in this module */
48 
49 #define YYLMAX BUFSIZ
50 #define YYNEWLINE 10
51 
52 /* The following statements define a routine for placing characters into
53  the lexical analyzer's rescan buffer */
54 
55 #define unput(X) for (nc=strlen(X); nc > 0; yyunput(X[--nc]))
56 
57 extern int nc; /* Number of characters to unput */
58 
59 /* The following variables are defined in the module containing the
60  parser action routines. */
61 
62 extern AGGREGATE ODLroot_node; /* Pointer to root node of ODL tree */
63 extern AGGREGATE ODLcurrent_aggregate; /* Pointer to current aggregate node*/
64 
65 extern int ODLerror_count; /* Cumulative count of errors */
66 extern int ODLwarning_count; /* Cumulative count of warnings */
67 extern int ODLlinenumber_flag; /* Flag to control line no. output */
68 
69 /* The following variables are defined in the lexical analyzer module */
70 
71 extern FILE *yyin; /* Pointer to file for parser input */
72 extern FILE *yyout; /* Pointer to file for parser output */
73 
74 extern char yysbuf[YYLMAX]; /* Lexical analysis rescan buffer */
75 extern char *yysptr; /* Pointer into lexical rescan buffer */
76 
77 extern int yylineno; /* Current input line number */
78 extern int yyprevious; /* Previous lexical analysis state */
79 
80 
81 int ReadValue (
82 
83  AGGREGATE node,
84  char *parameter_name,
85  char *value_string)
86 
87 {
88 
89  /* Reset pointers for the files to be used by the parser */
90 
91  yyin = NULL;
92  yyout = NULL;
93 
94  /* Reset other variables used by the lexical analyzer */
95 
97  yysptr = yysbuf;
98  yylineno = 1;
99 
100  /* Initialize the error and warning counters, and reset the line number
101  output flag so that line numbers won't be reported in any error
102  messages */
103 
104  ODLerror_count = 0;
105  ODLwarning_count = 0;
106  ODLlinenumber_flag = 0;
107 
108  /* Initialize the node pointers */
109 
110  ODLroot_node = node;
111  ODLcurrent_aggregate = node;
112 
113  /* Place the parameter name and value string into the lexical analyzer's
114  rescan buffer, along with an END statement to terminate the mini-label
115  we're creating */
116 
117  unput ("\nEND\n");
118  unput (value_string);
119  unput ("=");
120  unput (parameter_name);
121 
122  /* Call the parser to read in and process the value. The result will be
123  a new parameter node (along with the associated value information)
124  attached to the specified aggregate node */
125 
126  if (yyparse() != 0)
127  {
128  return (0);
129  }
130  else
131  {
132  return (1);
133  }
134 }
135 
136 
AGGREGATE ODLcurrent_aggregate
Definition: parsact.c:56
AGGREGATE ODLroot_node
Definition: parsact.c:55
char yysbuf[YYLMAX]
FILE * yyout
Definition: lexan.c:20
int nc
Definition: lexan.c:84
int yyparse()
Definition: parser.c:408
FILE * yyin
Definition: lexan.c:20
#define YYLMAX
Definition: rdvalue.c:49
int ODLlinenumber_flag
Definition: output.c:60
char * yysptr
int yyprevious
Definition: lexan.c:1960
#define YYNEWLINE
Definition: rdvalue.c:50
int ReadValue(AGGREGATE node, char *parameter_name, char *value_string)
Definition: rdvalue.c:81
int yylineno
int ODLerror_count
Definition: output.c:58
#define unput(X)
Definition: rdvalue.c:55
int ODLwarning_count
Definition: output.c:59

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51