⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interp_read.cc

📁 Source code for an Numeric Cmputer
💻 CC
📖 第 1 页 / 共 5 页
字号:
  else if(_setup.skipping_o != 0)  {      // if we are skipping, do NOT evaluate non-olines      return INTERP_OK;  }  else if (line[counter] == 'n')  {    CHP(read_line_number(line, &counter, block));  }  for (; counter < length;) {    CHP(read_one_item(line, &counter, block, parameters));  }  return INTERP_OK;}/****************************************************************************//*! read_jReturned Value: int   If read_real_value returns an error code, this returns that code.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The first character read is not j:      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED   2. A j_coordinate has already been inserted in the block.      NCE_MULTIPLE_J_WORDS_ON_ONE_LINESide effects:   counter is reset.   The j_flag in the block is turned on.   A j_coordinate setting is inserted in the block.Called by: read_one_itemWhen this function is called, counter is pointing at an item on theline that starts with the character 'j', indicating a j_coordinatesetting. The function reads characters which tell how to set thecoordinate, up to the start of the next item or the end of the line.This information is inserted in the block. The counter is then set topoint to the character following.The value may be a real number or something that evaluates to a realnumber, so read_real_value is used to read it. Parameters may beinvolved.*/int Interp::read_j(char *line,   //!< string: line of RS274 code being processed                      int *counter, //!< pointer to a counter for position on the line                   block_pointer block,  //!< pointer to a block being filled from the line                   double *parameters)   //!< array of system parameters                    {  static char name[] = "read_j";  double value;  int status;  CHK((line[*counter] != 'j'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);  *counter = (*counter + 1);  CHK((block->j_flag != OFF), NCE_MULTIPLE_J_WORDS_ON_ONE_LINE);  CHP(read_real_value(line, counter, &value, parameters));  block->j_flag = ON;  block->j_number = value;  return INTERP_OK;}/****************************************************************************//*! read_kReturned Value: int   If read_real_value returns an error code, this returns that code.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The first character read is not k:      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED   2. A k_coordinate has already been inserted in the block:      NCE_MULTIPLE_K_WORDS_ON_ONE_LINESide effects:   counter is reset.   The k_flag in the block is turned on.   A k_coordinate setting is inserted in the block.Called by: read_one_itemWhen this function is called, counter is pointing at an item on theline that starts with the character 'k', indicating a k_coordinatesetting. The function reads characters which tell how to set thecoordinate, up to the start of the next item or the end of the line.This information is inserted in the block. The counter is then set topoint to the character following.The value may be a real number or something that evaluates to a realnumber, so read_real_value is used to read it. Parameters may beinvolved.*/int Interp::read_k(char *line,   //!< string: line of RS274 code being processed                      int *counter, //!< pointer to a counter for position on the line                   block_pointer block,  //!< pointer to a block being filled from the line                   double *parameters)   //!< array of system parameters                    {  static char name[] = "read_k";  double value;  int status;  CHK((line[*counter] != 'k'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);  *counter = (*counter + 1);  CHK((block->k_flag != OFF), NCE_MULTIPLE_K_WORDS_ON_ONE_LINE);  CHP(read_real_value(line, counter, &value, parameters));  block->k_flag = ON;  block->k_number = value;  return INTERP_OK;}/****************************************************************************//*! read_lReturned Value: int   If read_integer_value returns an error code, this returns that code.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The first character read is not l:      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED   2. An l_number has already been inserted in the block:      NCE_MULTIPLE_L_WORDS_ON_ONE_LINE   3. the l_number is negative: NCE_NEGATIVE_L_WORD_USEDSide effects:   counter is reset to the character following the l number.   An l code is inserted in the block as the value of l.Called by: read_one_itemWhen this function is called, counter is pointing at an item on theline that starts with the character 'l', indicating an L code.The function reads characters which give the (integer) value of theL code.L codes are used for:1. the number of times a canned cycle should be repeated.2. a key with G10.*/int Interp::read_l(char *line,   //!< string: line of RS274/NGC code being processed                  int *counter, //!< pointer to a counter for position on the line                   block_pointer block,  //!< pointer to a block being filled from the line                   double *parameters)   //!< array of system parameters                    {  static char name[] = "read_l";  int value;  int status;  CHK((line[*counter] != 'l'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);  *counter = (*counter + 1);  CHK((block->l_number > -1), NCE_MULTIPLE_L_WORDS_ON_ONE_LINE);  CHP(read_integer_value(line, counter, &value, parameters));  CHK((value < 0), NCE_NEGATIVE_L_WORD_USED);  block->l_number = value;  return INTERP_OK;}/****************************************************************************//*! read_line_numberReturned Value: int   If read_integer_unsigned returns an error code, this returns that code.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The first character read is not n:      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED   2. The line number is too large (more than 99999):      NCE_LINE_NUMBER_GREATER_THAN_99999Side effects:   counter is reset to the character following the line number.   A line number is inserted in the block.Called by: read_itemsWhen this function is called, counter is pointing at an item on theline that starts with the character 'n', indicating a line number.The function reads characters which give the (integer) value of theline number.Note that extra initial zeros in a line number will not cause theline number to be too large.*/int Interp::read_line_number(char *line, //!< string: line of RS274    code being processed                             int *counter,       //!< pointer to a counter for position on the line                             block_pointer block)        //!< pointer to a block being filled from the line {  static char name[] = "read_line_number";  int value;  int status;  CHK(((line[*counter] != 'n') && (line[*counter] != 'o')),      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);  *counter = (*counter + 1);  CHP(read_integer_unsigned(line, counter, &value));/* This next test is problematic as many CAM systems will exceed this !  CHK((value > 99999), NCE_LINE_NUMBER_GREATER_THAN_99999); */  block->line_number = value;  return INTERP_OK;}/****************************************************************************//*! read_mReturned Value:   If read_integer_value returns an error code, this returns that code.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The first character read is not m:      NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED   2. The value is negative: NCE_NEGATIVE_M_CODE_USED   3. The value is greater than 199: NCE_M_CODE_GREATER_THAN_199   4. The m code is not known to the system: NCE_UNKNOWN_M_CODE_USED   5. Another m code in the same modal group has already been read:      NCE_TWO_M_CODES_USED_FROM_SAME_MODAL_GROUPSide effects:   counter is reset to the character following the m number.   An m code is inserted as the value of the appropriate mode in the   m_modes array in the block.   The m code counter in the block is increased by 1.Called by: read_one_itemWhen this function is called, counter is pointing at an item on theline that starts with the character 'm', indicating an m code.The function reads characters which give the (integer) value of them code.read_integer_value allows a minus sign, so a check for a negative valueis needed here, and the parameters argument is also needed.*/int Interp::read_m(char *line,   //!< string: line of RS274 code being processed                     int *counter, //!< pointer to a counter for position on the line                  block_pointer block,  //!< pointer to a block being filled from the line                  double *parameters)   //!< array of system parameters                   {  static char name[] = "read_m";  int value;  int mode;  int status;  CHK((line[*counter] != 'm'), NCE_BUG_FUNCTION_SHOULD_NOT_HAVE_BEEN_CALLED);  *counter = (*counter + 1);  CHP(read_integer_value(line, counter, &value, parameters));  CHK((value < 0), NCE_NEGATIVE_M_CODE_USED);  CHK((value > 199), NCE_M_CODE_GREATER_THAN_199);  mode = _ems[value];  CHK((mode == -1), NCE_UNKNOWN_M_CODE_USED);  CHK((block->m_modes[mode] != -1),      NCE_TWO_M_CODES_USED_FROM_SAME_MODAL_GROUP);  block->m_modes[mode] = value;  block->m_count++;  if (value >= 100 && value < 200) {    block->user_m = 1;  }  return INTERP_OK;}/****************************************************************************//*! read_one_itemReturned Value: int   If a reader function which is called returns an error code, that   error code is returned.   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. the first character read is not a known character for starting a   word: NCE_BAD_CHARACTER_USEDSide effects:   This function reads one item from a line of RS274/NGC code and inserts   the information in a block. System parameters may be reset.Called by: read_items.When this function is called, the counter is set so that the positionbeing considered is the first position of a word. The character atthat position must be one known to the system.  In this version thosecharacters are: a,b,c,d,f,g,h,i,j,k,l,m,n,p,q,r,s,t,x,y,z,(,#.However, read_items calls read_line_number directly if the first wordbegins with n, so no read function is included in the "_readers" arrayfor the letter n. Thus, if an n word is encountered in the middle ofa line, this function reports NCE_BAD_CHARACTER_USED.The function looks for a letter or special character and matches it toa pointer to a function in _readers[] - The position of the functionpointers in the array match their ASCII number.Once the character has been matched, the function calls a selected functionaccording to what the letter or character is.  The selected function willbe responsible to consider all the characters that comprise the remainderof the item, and reset the pointer so that it points to the next characterafter the end of the item (which may be the end of the line or the firstcharacter of another item).After an item is read, the counter is set at the index of thenext unread character. The item data is stored in the block.It is expected that the format of a comment will have been checked;this is being done by close_and_downcase. Bad format comments willhave prevented the system from getting this far, so that this functioncan assume a close parenthesis will be found when an open parenthesishas been found, and that comments are not nested.*/int Interp::read_one_item(char *line,    //!< string: line of RS274/NGC code being processed                         int *counter,  //!< pointer to a counter for position on the line                          block_pointer block,   //!< pointer to a block being filled from the line                          double *parameters)    //!< array of system parameters                    {  static char name[] = "read_one_item";  int status;  read_function_pointer function_pointer;  char letter;  letter = line[*counter];      /* check if in array range */  CHK(((letter < 0) || (letter > 'z')), NCE_BAD_CHARACTER_USED);  function_pointer = _readers[(int) letter]; /* Find the function pointer in the array */  CHK((function_pointer == 0), NCE_BAD_CHARACTER_USED);  CHP((*this.*function_pointer)(line, counter, block, parameters)); /* Call the function */   return INTERP_OK;}/****************************************************************************//*! read_operationReturned Value: int   If any of the following errors occur, this returns the error code shown.   Otherwise, it returns INTERP_OK.   1. The operation is unknown:      NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_A      NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_M      NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_O      NCE_UNKNOWN_OPERATION_NAME_STARTING_WITH_X      NCE_UNKNOWN_OPERATION   2. The line ends without closing the expression: NCE_UNCLOSED_EXPRESSIONSide effects:   An integer representing the operation is put into what operation points   at.  The counter is reset to point to the first character after the   operation.Called by: read_real_expressionThis expects to be reading a binary operation (+, -, /, *, **, and,mod, or, xor) or a right bracket (]). If one of these is found, thevalue of operation is set to the symbolic value for that operation.If not, an error is reported as described above.*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -