* Rewrite the error cost comparison in terms of explicit, discrete conditions. * Allow merging versions have different error costs. * Store the depth of each stack version since the last error. Use this state to prevent incorrect merging. * Sort the stack versions in order of preference and put a hard limit on the version count.
35 lines
649 B
C
35 lines
649 B
C
#ifndef RUNTIME_ERROR_COSTS_H_
|
|
#define RUNTIME_ERROR_COSTS_H_
|
|
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define ERROR_STATE 0
|
|
#define ERROR_COST_PER_SKIPPED_TREE 100
|
|
#define ERROR_COST_PER_SKIPPED_LINE 30
|
|
#define ERROR_COST_PER_SKIPPED_CHAR 1
|
|
|
|
typedef struct {
|
|
unsigned count;
|
|
unsigned cost;
|
|
unsigned push_count;
|
|
} ErrorStatus;
|
|
|
|
typedef enum {
|
|
ErrorComparisonTakeLeft,
|
|
ErrorComparisonPreferLeft,
|
|
ErrorComparisonNone,
|
|
ErrorComparisonPreferRight,
|
|
ErrorComparisonTakeRight,
|
|
} ErrorComparison;
|
|
|
|
ErrorComparison error_status_compare(ErrorStatus a, ErrorStatus b, bool can_merge);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|