< prev index next >

src/hotspot/share/adlc/adlparse.cpp

Print this page
rev 50962 : [mq]: 8207011


4547   int junk = 0;
4548   if (include_location && _AD._adlocation_debug && !is_int_token(token2, junk)) {
4549     // Prepend location descriptor, for debugging.
4550     char* location = get_line_string(line);
4551     char* end_loc  = end_line_marker();
4552     char* result = (char *)malloc(strlen(location) + strlen(token2) + strlen(end_loc) + 1);
4553     strcpy(result, location);
4554     strcat(result, token2);
4555     strcat(result, end_loc);
4556     token2 = result;
4557     free(location);
4558   }
4559   return token2;
4560 }
4561 
4562 //------------------------------get_ident_common-------------------------------
4563 // Looks for an identifier in the buffer, and turns it into a null terminated
4564 // string(still inside the file buffer).  Returns a pointer to the string or
4565 // NULL if some other token is found instead.
4566 char *ADLParser::get_ident_common(bool do_preproc) {
4567   register char c;
4568   char *start;                    // Pointer to start of token
4569   char *end;                      // Pointer to end of token
4570 
4571   if( _curline == NULL )          // Return NULL at EOF.
4572     return NULL;
4573 
4574   skipws_common(do_preproc);      // Skip whitespace before identifier
4575   start = end = _ptr;             // Start points at first character
4576   end--;                          // unwind end by one to prepare for loop
4577   do {
4578     end++;                        // Increment end pointer
4579     c = *end;                     // Grab character to test
4580   } while ( ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))
4581             || ((c >= '0') && (c <= '9'))
4582             || ((c == '_')) || ((c == ':')) || ((c == '#')) );
4583   if (start == end) {             // We popped out on the first try
4584     // It can occur that `start' contains the rest of the input file.
4585     // In this case the output should be truncated.
4586     if (strlen(start) > 24) {
4587       char buf[32];


4745 
4746   if (ident == NULL) {
4747     parse_err(SYNERR, "missing %s identifier at %c\n", nameDescription, _curchar);
4748   }
4749   else {
4750     if (dict[ident] != NULL) {
4751       parse_err(SYNERR, "duplicate name %s for %s\n", ident, nameDescription);
4752       ident = NULL;
4753     }
4754   }
4755 
4756   return ident;
4757 }
4758 
4759 
4760 //------------------------------get_int----------------------------------------
4761 // Looks for a character string integer in the buffer, and turns it into an int
4762 // invokes a parse_err if the next token is not an integer.
4763 // This routine does not leave the integer null-terminated.
4764 int ADLParser::get_int(void) {
4765   register char c;
4766   char         *start;            // Pointer to start of token
4767   char         *end;              // Pointer to end of token
4768   int           result;           // Storage for integer result
4769 
4770   if( _curline == NULL )          // Return NULL at EOF.
4771     return 0;
4772 
4773   skipws();                       // Skip whitespace before identifier
4774   start = end = _ptr;             // Start points at first character
4775   c = *end;                       // Grab character to test
4776   while ((c >= '0' && c <= '9') || (c == '-' && end == start)) {
4777     end++;                        // Increment end pointer
4778     c = *end;                     // Grab character to test
4779   }
4780   if (start == end) {             // We popped out on the first try
4781     parse_err(SYNERR, "integer expected at %c\n", c);
4782     result = 0;
4783   }
4784   else {
4785     _curchar = c;                 // Save the first character of next token




4547   int junk = 0;
4548   if (include_location && _AD._adlocation_debug && !is_int_token(token2, junk)) {
4549     // Prepend location descriptor, for debugging.
4550     char* location = get_line_string(line);
4551     char* end_loc  = end_line_marker();
4552     char* result = (char *)malloc(strlen(location) + strlen(token2) + strlen(end_loc) + 1);
4553     strcpy(result, location);
4554     strcat(result, token2);
4555     strcat(result, end_loc);
4556     token2 = result;
4557     free(location);
4558   }
4559   return token2;
4560 }
4561 
4562 //------------------------------get_ident_common-------------------------------
4563 // Looks for an identifier in the buffer, and turns it into a null terminated
4564 // string(still inside the file buffer).  Returns a pointer to the string or
4565 // NULL if some other token is found instead.
4566 char *ADLParser::get_ident_common(bool do_preproc) {
4567   char c;
4568   char *start;                    // Pointer to start of token
4569   char *end;                      // Pointer to end of token
4570 
4571   if( _curline == NULL )          // Return NULL at EOF.
4572     return NULL;
4573 
4574   skipws_common(do_preproc);      // Skip whitespace before identifier
4575   start = end = _ptr;             // Start points at first character
4576   end--;                          // unwind end by one to prepare for loop
4577   do {
4578     end++;                        // Increment end pointer
4579     c = *end;                     // Grab character to test
4580   } while ( ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))
4581             || ((c >= '0') && (c <= '9'))
4582             || ((c == '_')) || ((c == ':')) || ((c == '#')) );
4583   if (start == end) {             // We popped out on the first try
4584     // It can occur that `start' contains the rest of the input file.
4585     // In this case the output should be truncated.
4586     if (strlen(start) > 24) {
4587       char buf[32];


4745 
4746   if (ident == NULL) {
4747     parse_err(SYNERR, "missing %s identifier at %c\n", nameDescription, _curchar);
4748   }
4749   else {
4750     if (dict[ident] != NULL) {
4751       parse_err(SYNERR, "duplicate name %s for %s\n", ident, nameDescription);
4752       ident = NULL;
4753     }
4754   }
4755 
4756   return ident;
4757 }
4758 
4759 
4760 //------------------------------get_int----------------------------------------
4761 // Looks for a character string integer in the buffer, and turns it into an int
4762 // invokes a parse_err if the next token is not an integer.
4763 // This routine does not leave the integer null-terminated.
4764 int ADLParser::get_int(void) {
4765   char          c;
4766   char         *start;            // Pointer to start of token
4767   char         *end;              // Pointer to end of token
4768   int           result;           // Storage for integer result
4769 
4770   if( _curline == NULL )          // Return NULL at EOF.
4771     return 0;
4772 
4773   skipws();                       // Skip whitespace before identifier
4774   start = end = _ptr;             // Start points at first character
4775   c = *end;                       // Grab character to test
4776   while ((c >= '0' && c <= '9') || (c == '-' && end == start)) {
4777     end++;                        // Increment end pointer
4778     c = *end;                     // Grab character to test
4779   }
4780   if (start == end) {             // We popped out on the first try
4781     parse_err(SYNERR, "integer expected at %c\n", c);
4782     result = 0;
4783   }
4784   else {
4785     _curchar = c;                 // Save the first character of next token


< prev index next >