Object* native_file_eof(Object *cxt, Object *frame, Object *self) { Object *stack = get(cxt, frame, "stack"); FileBuffer *file_buf = get_file_buffer(self); if ( file_buf == 0 ) { return new_exception(cxt, frame, "Expected a file as first argument"); } if ( feof(file_buf->file) ) { push(cxt, stack, get_true(cxt)); } else { push(cxt, stack, get_false(cxt)); } return frame; };
/** @brief Get the next JSON node -- be it string, number, hash, or whatever. @param parser Pointer to a Parser. @param firstc The first character in the part that we're parsing. @return Pointer to the next JSON node, or NULL upon error. The first character tells us what kind of thing we're parsing next: a string, an array, a hash, a number, a boolean, or a null. Branch accordingly. In the case of an array or a hash, this function indirectly calls itself in order to parse subordinate nodes. */ static jsonObject* get_json_node( Parser* parser, char firstc ) { jsonObject* obj = NULL; // Branch on the first character if( '"' == firstc ) { const char* str = get_string( parser ); if( str ) { obj = jsonNewObject( NULL ); obj->type = JSON_STRING; obj->value.s = strdup( str ); } } else if( '[' == firstc ) { obj = get_array( parser ); } else if( '{' == firstc ) { if( parser->decode ) obj = get_decoded_hash( parser ); else obj = get_hash( parser ); } else if( 'n' == firstc ) { obj = get_null( parser ); } else if( 't' == firstc ) { obj = get_true( parser ); } else if( 'f' == firstc ) { obj = get_false( parser ); } else if( isdigit( (unsigned char) firstc ) || '.' == firstc || '-' == firstc || '+' == firstc || 'e' == firstc || 'E' == firstc ) { obj = get_number( parser, firstc ); } else { report_error( parser, firstc, "Unexpected character" ); } return obj; }