Waitrud Weber’s blog

things and reminders for memories

Code Analyzer 003

20180421 2nd
In 20180421 1st I could point the problem and am trying to solve it now. I added the codes(20180421) before analyzer call the put_token.

int parse_libraries ( FILE *fp, int file_end ) {
 char dummy[1];

 for( int i=0; i<file_end; i++ ) {
  m_fread ( dummy, 1, fp);

  switch ( dummy[0] ) {
  case ' ':
   // 20180421 for debug.
   printf( "token: %s\n", token);
   exit( - 1 );
   analyze_libraries ( token );
   parse_library_name ( fp, file_end );
   break;
  case '/':
   if ( parse_comment_out ( fp, file_end ) == 1 ) return 1;
   break;
  }

  // 20180421
  if ( line_end ( dummy[0] ) == 1 && m_cnt_tkn == 0 ) {
   printf(" line_end and m_cnt_tkn = 0 ");
   //exit( -1);
   break;
  }

  printf( "parse_libraries\n" );
  token = put_token ( dummy[0] );
 }

 return 1;
}

The function analyze_libraries( char* tkn ) allows keyword: "package" and "import".
So, I temporarily programmed as the below and would modify on the day which is advantageous to my work.

int analyze_libraries ( char* tkn ) {

 // printf("analyze libraries line %d raw %d it's not keyword: %s\n", m_line, m_raw, tkn );
 // exit(-1);


 if ( compare ( tkn, (char *)"package" )  == 1 ) {

  printf("it's keyword: %s\n", tkn );

 } else if ( compare ( tkn, (char *)"import" ) == 1 ) {

  printf("it's not keyword: %s\n", tkn );
 } else {

  printf("line %d raw %d it's not keyword: %s\n", m_line, m_raw, tkn );
  exit(-1);
 }

 return 1;
}

 

> mingw32-make all
gcc -Wall -O3 -o analyzer.o -c analyzer.cpp
gcc array_counter.o parse.o analyzer.o  -o analyzer.exe
> .\analyzer.exe .\HomePDFPrinter.java
 line_end and m_cnt_tkn = 0 parse_libraries
parse_libraries
parse_libraries
parse_libraries
parse_libraries
parse_libraries
parse_libraries
token: package
>

Please download the bellow freely but care about HomePDFPrinter.java.

https://github.com/WaitrudWeber/source_zip/blob/master/20180421-2nd.zip


HomePDFPrinter.java which I analyzed is the part of Sweet Home 3D.
Copyright of Sweet Home 3D.

Creative Commons — Attribution 3.0 Unported — CC BY 3.0