1 /* 2 * This program exists purely to allow 'make distcheck' to check 3 * that an installation will allow a simple SEE program to 4 * be compiled and run. 5 */ 6 7 #include <see/see.h> 8 9 /* Simple example of using the interpreter */ 10 int main()11main() 12 { 13 struct SEE_interpreter interp_storage, *interp; 14 struct SEE_input *input; 15 SEE_try_context_t try_ctxt; 16 struct SEE_value result; 17 char *program_text = "Math.sqrt(3 + 4 * 7) + 9"; 18 19 /* Initialise an interpreter */ 20 SEE_interpreter_init(&interp_storage); 21 interp = &interp_storage; 22 23 /* Create an input stream that provides program text */ 24 input = SEE_input_utf8(interp, program_text); 25 26 /* Establish an exception context */ 27 SEE_TRY(interp, try_ctxt) { 28 /* Call the program evaluator */ 29 SEE_Global_eval(interp, input, &result); 30 31 /* Print the result */ 32 if (SEE_VALUE_GET_TYPE(&result) == SEE_NUMBER) 33 printf("The answer is %f\n", result.u.number); 34 else { 35 printf("Unexpected answer\n"); 36 exit(1); 37 } 38 } 39 40 /* Finally: */ 41 SEE_INPUT_CLOSE(input); 42 43 /* Catch any exceptions */ 44 if (SEE_CAUGHT(try_ctxt)) { 45 printf("Unexpected exception\n"); 46 exit(1); 47 } 48 49 exit(0); 50 } 51