~ubuntu-branches/ubuntu/lucid/gcalctool/lucid-updates

« back to all changes in this revision

Viewing changes to src/mp-equation.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-04-07 19:41:56 UTC
  • mfrom: (1.3.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100407194156-hgj8g002ffce2de0
Tags: 5.30.0.is.5.28.2-0ubuntu1
Downgrade to 5.28.2 as the new version does not support number bases
as well.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  Copyright (c) 2004-2008 Sami Pietila
 
1
 
 
2
/*  $Header$
 
3
 *
 
4
 *  Copyright (C) 2004-2008 Sami Pietila
2
5
 *  Copyright (c) 2008-2009 Robert Ancell
3
6
 *
4
7
 *  This program is free software; you can redistribute it and/or modify
22
25
 
23
26
#include "mp.h"
24
27
 
25
 
typedef enum
26
 
{
27
 
    PARSER_ERR_NONE = 0,
28
 
    PARSER_ERR_INVALID,
29
 
    PARSER_ERR_OVERFLOW,
30
 
    PARSER_ERR_UNKNOWN_VARIABLE,
31
 
    PARSER_ERR_UNKNOWN_FUNCTION,
32
 
    PARSER_ERR_UNKNOWN_CONVERSION,
33
 
    PARSER_ERR_MP
34
 
} MPErrorCode;
 
28
#define PARSER_ERR_INVALID          1
 
29
#define PARSER_ERR_BITWISEOP        3
 
30
#define PARSER_ERR_MODULUSOP        4
 
31
#define PARSER_ERR_OVERFLOW         5
 
32
#define PARSER_ERR_UNKNOWN_VARIABLE 6
 
33
#define PARSER_ERR_UNKNOWN_FUNCTION 7
 
34
#define PARSER_ERR_INVALID_BASE     8
 
35
#define PARSER_ERR_MP               9
35
36
 
36
37
/* Options for parser */
37
38
typedef struct {
 
39
    /* The numeric base (e.g 2, 8, 10, 16) */
 
40
    int base;
 
41
 
38
42
    /* The wordlength for binary operations in bits (e.g. 8, 16, 32) */
39
43
    int wordlen;
40
 
 
 
44
    
41
45
    /* Units for angles (e.g. radians, degrees) */
42
46
    MPAngleUnit angle_units;
43
 
 
 
47
    
44
48
    // FIXME:
45
49
    // int enable_builtins;
46
 
 
 
50
    
47
51
    /* Data to pass to callbacks */
48
52
    void *callback_data;
49
 
  
50
 
    /* Function to check if a variable is defined */
51
 
    int (*variable_is_defined)(const char *name);
52
 
 
 
53
    
53
54
    /* Function to get variable values */
54
55
    int (*get_variable)(const char *name, MPNumber *z, void *data);
55
 
 
 
56
    
56
57
    /* Function to set variable values */
57
58
    void (*set_variable)(const char *name, const MPNumber *x, void *data);
58
59
 
59
 
    /* Function to check if a function is defined */
60
 
    int (*function_is_defined)(const char *name);
61
 
 
62
60
    /* Function to solve functions */
63
61
    int (*get_function)(const char *name, const MPNumber *x, MPNumber *z, void *data);
64
 
 
65
 
    /* Function to convert units */
66
 
    int (*convert)(const MPNumber *x, const char *x_units, const char *z_units, MPNumber *z, void *data);
67
62
} MPEquationOptions;
68
63
 
69
 
MPErrorCode mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *result, char **error_token);
70
 
const char *mp_error_code_to_string(MPErrorCode error_code);
 
64
int mp_equation_parse(const char *expression, MPEquationOptions *options, MPNumber *result);
71
65
 
72
 
int sub_atoi(const char *data);
73
 
int super_atoi(const char *data);
74
66
#endif