Пример #1
0
int	my_mock_string_push_fail_at(struct s_string *string, char c)
{
  if (string_push_fail_at <= 0)
    return (-1);
  string_push_fail_at--;
  return (string_push(string, c));
}
Пример #2
0
interrupt void monstermash_isr(void){
	EALLOW;
	unsigned int value;
	unsigned long temp;
	value = ADC_get();

	if(SRAMaddress <= 0x29FFFF & a == 0){
		*SRAMaddress = value;
		SRAMaddress++;

	}
	else if(SRAMaddress <= 0x29FFFF && a ==1){
		temp = *SRAMaddress;
		temp = temp+value;
		temp = temp/2;
		value = temp;
		//TODO:this is where attenuation would go
		*SRAMaddress = value;
		SRAMaddress++;
		if(SRAMaddress > 0x29FFFF){

			b = 1;

		}
	}
	else if(b == 1){
		DINT;
		SRAMaddress = 0x260000;
		changeFunctions(samplingRate);
		EINT;
		ERTM;
	}
	else{


		SRAMaddress = 0x260000;
		a = 1;

		string_push("press 4 when second sample is ready");
		int test = keypadScan();
		while(test != 4){
			test = keypadScan();
		}
		LCDclear();
		//changeFunctions();
		//EINT;   // Enable Global interrupt INTM
		//ERTM;   // Enable Global realtime interrupt DBGM

	}
}
Пример #3
0
Token *lex_get_next_lexeme(ParseState *state) {
  String *word = String_create("");

  int starting_index = 0; // used to track progress against comments
  int column = 0;
  int line =   0;
  char c =     lex_state_current_char(state);
  Boolean should_continue = true;

  while ( lex_state_in_progress(state) && should_continue ) {
    // strings, comments, regex, etc ...
    if ( string_empty(word) && lex_state_opens_at_current(state) ) {
      starting_index = lex_state_current(state);
      lex_state_lexical_bookend(state) = lex_state_closer(state);
    }

    if ( lex_state_current_is_significant(state) ) {
      starting_index = starting_index ? starting_index : (lex_state_current(state));
      column = column ? column : (lex_state_column(state));
      line =   line   ? line   : (lex_state_line(state));
      string_push(word, c);
    }

    // update lex state for new line
    if ( char_is_line_end(c) ) {
      lex_state_start_new_line(state);
    }

    // check for termination of strings and other bookends that may contain spaces
    if ( lex_state_is_open(state) && starting_index < lex_state_current(state) ) {
      // regexes are special, because there can be characters after the ending '/'
      // so we have to switch the state
      lex_state_transition_regex_if_needed(state);

      if ( lex_state_will_close(state) ) {
        lex_state_close(state);
        should_continue = false;
      }
    } else if ( lex_state_current_is_significant(state) && (
        char_is_line_end(c) || char_is_statement_end(c) ||         // line ends usually significant of a statement end
        lex_state_end_of_word(state) ||                        // end of normal word sequence
        word_is_method_selector(word, c)  ||                       // '.'
        char_is_syntax(c) ||                                       // '(' ')' ','
        char_is_colon(lex_state_next_char(state)) ||           // : appearing after first char breaks the word
        lex_state_will_end_word_by_dot(state, word))       ) { // next char is a dot, and word is not a number
      should_continue = false;
    }

    // move to next character
    lex_state_advance(state);
    c = lex_state_current_char(state);
  }

  if ( string_empty(word) ) {
    string_free(word);
    return NULL;
  }

  Token *lexeme = Token_create(word, line, column);
  check_mem(lexeme);

  return lexeme;
error:
  return NULL;
}