Exemple #1
0
void tex::scan_file_name ()
	{
	name_in_progress = TRUE;
	get_nbx_token();
	begin_name();
	loop {
		if (cur_cmd > OTHER_CHAR || cur_chr > 255) {
			back_input();
			break;
			}
		if (!more_name(cur_chr))
			break;
		get_x_token();
		}
	end_name();
	name_in_progress = FALSE;
	}
Exemple #2
0
void tex::start_input_prepare(const std::string& fname)
	{
	if(fname!="stdin") {
		if(fname.size()==0) {
			scan_file_name();
			if (cur_ext == null_str)
				cur_ext = str_tex;
			pack_file_name(cur_name, cur_area, cur_ext);
			}
		else {
			begin_name();
			strcpy(name_of_file, fname.c_str());
			name_str=name_of_file+strlen(fname.c_str());
			ext_str=null_str;
			area_str=null_str;
			end_name();
			pack_file_name(cur_name, cur_area, cur_ext);
			}
		loop {
			begin_file_reading();
			if((cur_file = a_open_in()))
				break;
			end_file_reading();
			if (cur_ext == str_tex) { // remove .tex and try again
				cur_ext = null_str;
				pack_file_name(cur_name, cur_area, cur_ext);
				begin_file_reading();
				if((cur_file = a_open_in()))
					break;
				end_file_reading();
				}
			std::cerr << "cannot open " << name_of_file << std::endl;
			throw std::logic_error("file not found");
			}
		}
	else {
Exemple #3
0
    element_ptr parse( std::istream & in, const std::string & msg )
    {
      char c = 0;  // current character
      element_ptr e( new element );

      in.get( c );
      if ( c == '<' ) in.get( c );

      e->name = get_name( c, in );
      eat_whitespace( c, in );

      // attributes
      while ( c != '>' )
      {
        attribute a;
        a.name = get_name( c, in );

        eat_delim( c, in, '=', msg );
        eat_delim( c, in, '\"', msg );

        a.value = get_value( c, in );

        e->attributes.push_back( a );
        eat_whitespace( c, in );
      }
      in.get( c ); // next after '>'
      eat_whitespace( c, in );

      // sub-elements
      while ( c == '<' )
      {
        if ( in.peek() == '/' ) break;
        e->elements.push_back( parse( in, msg ) );
        in.get( c ); // next after '>'
        eat_whitespace( c, in );
      }

      // content
      if ( c != '<' )
      {
        e->content += '\n';
        while ( c != '<' )
        {
          e->content += c;
          in.get( c );
        }
      }

      assert( c == '<' );
      in.get( c ); // next after '<'

      eat_delim( c, in, '/', msg );
      std::string end_name( get_name( c, in ) );
      if ( e->name != end_name )
        throw std::string("xml syntax error: beginning name ")
          + e->name + " did not match end name " + end_name
          + " (" + msg + ")";

      eat_delim( c, in, '>', msg );
      return e;
    }