Révision 129
sollyaIntegration-4.0/src/createObj-01.c (revision 129) | ||
---|---|---|
34 | 34 |
main(int argc, char** argv) |
35 | 35 |
{ |
36 | 36 |
//jmp_buf recover; |
37 |
sollya_obj_t functionObj = NULL; |
|
38 |
sollya_obj_t curVerbLevel = NULL; |
|
39 |
char *freeVariableName = NULL; |
|
40 |
char *functionString = NULL; |
|
41 |
char *initialFreeVariableName = NULL; |
|
42 |
char buffer[20]; |
|
37 |
pobyso_function_t functionObj = NULL; |
|
38 |
sollya_verbosity_t curVerbLevel = NULL; |
|
39 |
char *freeVariableName = NULL; |
|
40 |
char *functionString = NULL; |
|
41 |
char *initialFreeVariableName = NULL; |
|
43 | 42 |
|
44 | 43 |
|
45 | 44 |
/* check the command line arguments */ |
... | ... | |
60 | 59 |
return(1); |
61 | 60 |
} |
62 | 61 |
|
63 |
buffer[0] ='\0'; |
|
64 | 62 |
|
65 | 63 |
functionString = argv[1]; |
66 | 64 |
freeVariableName = argv[2]; |
... | ... | |
97 | 95 |
sollya_lib_close(); |
98 | 96 |
return(1); |
99 | 97 |
} |
98 |
/* Keep Sollya quiet. */ |
|
99 |
curVerbLevel = pobyso_set_verbosity_off(); |
|
100 | 100 |
/* Parse the function string. */ |
101 |
pobyso_set_verbosity_off(&curVerbLevel); |
|
102 | 101 |
functionObj = pobyso_parse_string(functionString); |
103 |
if (sollya_lib_obj_is_error(functionObj))
|
|
102 |
if (pobyso_is_error(functionObj))
|
|
104 | 103 |
{ |
105 | 104 |
fprintf(stderr, "%s: could not parse \"%s\". Aborting!\n", argv[0], functionString); |
106 | 105 |
sollya_lib_close(); |
107 | 106 |
return(1); |
108 | 107 |
} |
109 |
sollya_lib_fprintf(stdout, "%s: function: %b\n", argv[0], functionObj ); |
|
110 |
pobyso_autoprint(functionObj, NULL); |
|
111 |
sollya_lib_clear_obj(functionObj); |
|
108 |
//sollya_lib_fprintf(stdout, "%s: function: %b\n", argv[0], functionObj ); |
|
109 |
//pobyso_autoprint(functionObj, NULL); |
|
112 | 110 |
|
113 |
if (sollya_lib_obj_is_function(curVerbLevel)) |
|
111 |
pobyso_autoprint(functionObj, NULL); |
|
112 |
if (pobyso_is_function(functionObj)) |
|
114 | 113 |
{ |
115 |
pobyso_autoprint(curVerbLevel, NULL); |
|
116 | 114 |
fprintf(stdout, " is a function.\n"); |
117 | 115 |
} |
116 |
else |
|
117 |
{ |
|
118 |
fprintf(stdout, " is *not* a function!\n"); |
|
119 |
} |
|
118 | 120 |
pobyso_autoprint(curVerbLevel, NULL); |
119 | 121 |
pobyso_set_verbosity_to(curVerbLevel); |
120 | 122 |
sollya_lib_clear_obj(curVerbLevel); |
121 | 123 |
|
122 |
strncat(buffer, functionString, strlen(functionString) - 1); |
|
123 |
functionObj = pobyso_parse_string(buffer); |
|
124 |
if (sollya_lib_obj_is_error(functionObj)) |
|
125 |
{ |
|
126 |
fprintf(stderr, "%s: could not parse \"%s\". Aborting!\n", argv[0], functionString); |
|
127 |
sollya_lib_close(); |
|
128 |
return(1); |
|
129 |
} |
|
130 |
/* Attic from previous versions. */ |
|
131 |
#if 0 |
|
132 |
fprintf(stderr, "Name of variable: %s\n", getNameOfVariable()); |
|
133 |
if (functionNode->nodeType == VARIABLE) |
|
134 |
{ |
|
135 |
fprintf(stderr, "Node type is VARIABLE.\n"); |
|
136 |
if (getNameOfVariable != NULL) |
|
137 |
{ |
|
138 |
if (strcmp(freeVariableName, getNameOfVariable())) |
|
139 |
{ |
|
140 |
fprintf(stderr, "Could not parse %s. Aborting!\n", functionString); |
|
141 |
finishTool(); |
|
142 |
return(1); |
|
143 |
} |
|
144 |
} |
|
145 |
} |
|
124 |
sollya_lib_clear_obj(functionObj); |
|
146 | 125 |
|
147 |
variableNode = makeVariable(); |
|
148 |
|
|
149 |
powNode = makePow(variableNode, makeConstantDouble(3.0)); |
|
150 |
functionDiffNode = differentiate(functionNode); |
|
151 |
fprintf(stderr, "\tfunctionNode tree...\n"); |
|
152 |
fprintTree(stderr, functionNode); |
|
153 |
fprintf(stderr, "\n"); |
|
154 |
fprintf(stderr, "\t...end functionNode tree.\n"); |
|
155 |
fprintf(stderr, "\n"); |
|
156 |
fprintf(stderr, "\tfunctionDiffNode tree...\n"); |
|
157 |
fprintTree(stderr,functionDiffNode); |
|
158 |
fprintf(stderr, "\n"); |
|
159 |
fprintf(stderr, "\t...end functionDiffNode tree.\n"); |
|
160 |
fprintf(stderr, "\n\tvariableNode tree...\n"); |
|
161 |
fprintTree(stderr, variableNode); |
|
162 |
fprintf(stderr, "\n"); |
|
163 |
fprintf(stderr, "\t...end variableNode tree.\n"); |
|
164 |
fprintf(stderr, "\n\tpowNode tree...\n"); |
|
165 |
fprintTree(stderr, powNode); |
|
166 |
fprintf(stderr, "\n"); |
|
167 |
fprintf(stderr, "\t...end powNode tree.\n"); |
|
168 |
|
|
169 |
free_memory(variableNode); |
|
170 |
free_memory(functionNode); |
|
171 |
free_memory(functionDiffNode); |
|
172 |
#endif |
|
173 |
|
|
174 | 126 |
sollya_lib_close(); |
175 | 127 |
return(0); |
176 | 128 |
} /* End main */ |
Formats disponibles : Unified diff