Exemple #1
0
int lex_json(const char *input, struct lexer *lexer, struct lexer_result *result)
{
  int res = LEX_OK;
  static void* dispatch_table[] = {
      &&state_base, &&state_string, &&state_number, &&state_true,
      &&state_false, &&state_null
  };
  #define DISPATCH() { \
     if (!(lexer->position < lexer->length && lexer->result_num < lexer->result_limit && res == 0)) \
        return res; \
     goto *dispatch_table[lexer->current_state];\
     }

  DISPATCH();
  state_base:
    res = handle_base(input, lexer, result);
    DISPATCH();
  state_string:
    res = handle_string(input, lexer, result);
    DISPATCH();
  state_number:
    res = handle_number(input, lexer, result);
    DISPATCH();
  state_true:
    res = handle_ident(input, lexer, "true", RES_TRUE, result);
    DISPATCH();
  state_false:
    res = handle_ident(input, lexer, "false", RES_FALSE, result);
    DISPATCH();
  state_null:
    res = handle_ident(input, lexer, "null", RES_NULL, result);
    DISPATCH();

  return res;
}
Exemple #2
0
void SciCalc::cb_but_log_i(Fl_Button*, void*) {
  if (base > 10) handle_number(15.0);
else
	if (! inv)
	{
		value[top] = log10(value[top]);
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = pow(10.0, value[top]);
		set_display(value[top],NORM);
		ready = 1;
	};
}
Exemple #3
0
void SciCalc::cb_but_tan_i(Fl_Button*, void*) {
  if (base > 10) handle_number(14.0);
	else
	if (! inv)
	{
		value[top] = tan(to_drg(value[top]));
		set_display(value[top],NORM);
		ready = 1;
	}
	else
	{
		value[top] = from_drg(atan(value[top]));
		set_display(value[top],NORM);
		ready = 1;
	};
}
Exemple #4
0
inline void SciCalc::cb_but_cos_i(Fl_Button*, void*) {
  if (base > 10) handle_number(13.0);
  else
  	if (! inv) 
  	{
  		value[top] = cos(to_drg(value[top]));
  		set_display(value[top],NORM);
  		ready = 1;
  	}
  	else
  	{
  		value[top] = from_drg(acos(value[top]));
  		set_display(value[top],NORM);
  		ready = 1;
  	}
;}
Exemple #5
0
inline void SciCalc::cb_but_sqrt_i(Fl_Button*, void*) {
  if (base > 10) handle_number(10.0); 
  	else
  	if (! inv) 
  	{
  		value[top] = sqrt(value[top]);
  		set_display(value[top],NORM);
  		ready = 1;
  	}
  	else
  	{
  		value[top] = pow(value[top], 2.0);
  		set_display(value[top],NORM);
  		ready = 1;
  	}
;}
Exemple #6
0
void SciCalc::cb_but_6_i(Fl_Button*, void*) {
  handle_number(6);
}
Exemple #7
0
void SciCalc::cb_but_pow_i(Fl_Button*, void*) {
  if (base > 10)
		handle_number(11.0);
	else
		handle_operator(check_inv->value()?INVPOW:POW);
}
Exemple #8
0
void SciCalc::cb_but_dot_i(Fl_Button*, void*) {
  handle_number(DOT);
}
Exemple #9
0
inline void SciCalc::cb_but_9_i(Fl_Button*, void*) {
  handle_number(9);
}