Example #1
0
/*
 * Loop through reading the file one record at a time.
 * Parse each record.
 */
extern int Escher_xtUML_load(
  int argc,
  char * argv[]
)
{
  Escher_ClassNumber_t i;
  bool done = false;
  if ( 2 != argc ) {
    printf( "xtumlload <input xtUML file>\n" );
    return 1;
  }
  if ( (xtumlfile = fopen( argv[1], "r" )) == 0 ) {
    printf( "%s failed to open %s\n", argv[0], argv[1] );
    return 1;
  }
  init();               /* Initialize the xml storage area.      */
  printf( "Read %s on the %s command line.\n", argv[1], argv[0] );
  /*
   * Read a record.  Parse it.  Pass it.  Repeat until end of file.
   */
  while ( ! done ) {
    done = readrecord( &cursor );
    if ( statement() ) {
      if ( 0 != wordindex ) {
        Escher_load_instance( wordindex, word );
      }
    } else {
      printf( "Error:  Did not parse.\n" );
    }
  }
  for ( i = 0; i < 0 + ooaofooa_MAX_CLASS_NUMBERS; i++ ) {
    Escher_batch_relate( 0, i );
  }
  return 0;
}
Example #2
0
	void parse() {
		while(*p) {
			if(!readrecord())
				return;
			readtrail();
		}
	}
Example #3
0
/**
 * includelabel: procedure for tc= (or include=)
 *
 *	@param[in]	fp	file pointer
 *	@param[out]	sb	string buffer
 *	@param[in]	label	record label
 *	@param[in]	level	nest level for check
 *
 * This function may call itself (recursive)
 */
static void
includelabel(FILE *fp, STRBUF *sb, const char *label, int level)
{
	const char *savep, *p, *q;
	char *file;

	if (++level > allowed_nest_level)
		die("nested include= (or tc=) over flow.");
	/*
	 * Label can include a '@' and a following path name.
	 * Label: <label>[@<path>]
	 */
	if ((file = locatestring(label, "@", MATCH_FIRST)) != NULL) {
		*file++ = '\0';
		if ((p = makepath_with_tilde(file)) == NULL)
			die("config file must be absolute path. (%s)", file);
		fp = fopen(p, "r");
		if (fp == NULL)
			die("cannot open config file. (%s)", p);
	}
	if (!(savep = p = readrecord(fp, label)))
		die("label '%s' not found.", label);
	while ((q = locatestring(p, ":include=", MATCH_FIRST)) || (q = locatestring(p, ":tc=", MATCH_FIRST))) {
		STRBUF *inc = strbuf_open(0);

		strbuf_nputs(sb, p, q - p);
		q = locatestring(q, "=", MATCH_FIRST) + 1;
		for (; *q && *q != ':'; q++)
			strbuf_putc(inc, *q);
		includelabel(fp, sb, strbuf_value(inc), level);
		p = q;
		strbuf_close(inc);
	}
	strbuf_puts(sb, p);
	free((void *)savep);
	if (file)
		fclose(fp);
}
Example #4
0
/**
 * includelabel: procedure for @CODE{tc=} (or @CODE{include=})
 *
 *	@param[out]	sb	string buffer
 *	@param[in]	label	record label
 *	@param[in]	level	nest level for check
 */
static void
includelabel(STRBUF *sb, const char *label, int	level)
{
	const char *savep, *p, *q;

	if (++level > allowed_nest_level)
		die("nested include= (or tc=) over flow.");
	if (!(savep = p = readrecord(label)))
		die("label '%s' not found.", label);
	while ((q = locatestring(p, ":include=", MATCH_FIRST)) || (q = locatestring(p, ":tc=", MATCH_FIRST))) {
		STRBUF *inc = strbuf_open(0);

		strbuf_nputs(sb, p, q - p);
		q = locatestring(q, "=", MATCH_FIRST) + 1;
		for (; *q && *q != ':'; q++)
			strbuf_putc(inc, *q);
		includelabel(sb, strbuf_value(inc), level);
		p = q;
		strbuf_close(inc);
	}
	strbuf_puts(sb, p);
	free((void *)savep);
}