Ejemplo n.º 1
0
static void
autonumber(FlexBuffer *buffer, const Token& t)
{
  const AttributeRec *id = t.LookupAttr(SGMLName::intern("ID", 1));
  const AttributeRec *type = t.LookupAttr(SGMLName::intern("Type", 1));
  const AttributeRec *initial = t.LookupAttr(SGMLName::intern("Initial", 1));
  const AttributeRec *delta = t.LookupAttr(SGMLName::intern("Delta", 1));
  const AttributeRec *reset = t.LookupAttr(SGMLName::intern("Reset", 1));
  const AttributeRec *counter = t.LookupAttr(SGMLName::intern("Counter", 1));

  if(!id) throw(Unexpected("Autonumber: missing ID attribute"));
  if(!type) throw(Unexpected("Autonumber: missing Type attribute"));
  if(!initial) throw(Unexpected("Autonumber: missing Initial attribute"));
  if(!delta) throw(Unexpected("Autonumber: missing Delta attribute"));
  if(!reset) throw(Unexpected("Autonumber: missing Reset attribute"));
  if(!counter) throw(Unexpected("Autonumber: missing Counter attribute"));

  
  buffer->writeStr(id->getAttrValueString());
  buffer->writeStr(" = autonumber[\"");
  buffer->writeStr(type->getAttrValueString());
  buffer->writeStr("\", \"");
  buffer->writeStr(initial->getAttrValueString());
  buffer->writeStr("\", \"");
  buffer->writeStr(delta->getAttrValueString());
  buffer->writeStr("\", ");

  write_array(buffer,  counter->getAttrValueString(), 1);

  buffer->writeStr(", ");

  write_array(buffer, reset->getAttrValueString(), 1);

  buffer->writeStr("]\n\n");
}
Ejemplo n.º 2
0
Archivo: Task.C Proyecto: juddy/edcde
void TestTask2::markup(const Token &t)
{

  ComplexTask::markup( t );
  
  switch(t.type()){
  case START:

    /*
     * See if any OLIAS Architecture Form exists
     */

    if ( t.AttributeMatch( OLAF::OLIAS, OLAF::Graphic ) ) {
      f_base = t.level();

      if ( t.LookupAttr( OLAF::OL_data ) ) 
	ComplexTask::addSubTask( new OL_Data ( t, OLAF::OL_data ) );
    }
    break;

  case END:
    if ( f_base == t.level() ) {
      for ( int i=0; i < ComplexTask::used; i++ ) {
	OL_Data *t = ( OL_Data *) subtask(i);
	cout << "OL_Data found = " << t->content() << endl;
      }
    }
    break;

  default :
    break;

  }
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------------
OL_Data::OL_Data( const Token &t,
                  int DataType,
                  ActionType mode ):BaseData(t,mode)
{


    char *dbgStr;
    dbgStr = getenv("OL_DEBUG");
    dbgLevel = ( dbgStr ? atoi ( dbgStr ) : 0 );

    /* first generate grep all the mode info */
    istat = mode & IGNORE_ON;
    removeSpaces = mode & REMOVE_SPACES;

    f_name = strdup( t.file() );
    line_num = t.line();

    if ( istat && !Dispatch::OutsideIgnoreScope() ) {
        data_avail = 0;
        return;
    }

    const AttributeRec *attRec;
    if ( !(attRec = t.LookupAttr( DataType )) ) {

        if ( mode & GENERATE_ID ) {
            const char *str = unique_id();

            ValueBuffer.writeStr( str );
            data_avail = 1;
            data_complete = 1;
        }
        else {

            /*
             * The default rule kicks in, i.e use #CONTENT
             */

            addSubTask( new Content( t, mode) );
        }

        return;
    }

    tokContent.Parse( ( char *)attRec->getAttrValueString() );


    const OL_Expression *eptr = tokContent.exprlist;
    assert(eptr != NULL);

    switch ( eptr->type() ) {

    case REFERENCE:
    {
        BaseData *sub_data = new AttributeData(t, eptr->name(), mode );
        if ( sub_data ) {
            if (  data_avail= sub_data->DataWillBeAvailable() ) {
                ValueBuffer.write( sub_data->content(),
                                   sub_data->content_size() );
                data_complete = 1;
            }
            delete sub_data;
        }
    }

    break;

    case CONTENT:
        addSubTask( new Content(t, mode) );
        break;

    case CONCAT:
        addSubTask( new Concat( t,
                                (ExprList *)eptr->data_list(),
                                mode) );
        break;

    case FIRSTOF:
        addSubTask( new FirstOf( t,
                                 (ExprList *)eptr->data_list(),
                                 mode) );
        break;

    case GENERIC_ID:
        addSubTask( new GenericId( t,
                                   eptr->name(),
                                   mode) );
        break;

    case LITERAL:
        data_avail = 1;
        data_complete = 1;
        ValueBuffer.writeStr( ( const char *)eptr->data_list() );
        break;

    default:
        abort();
    }

}
Ejemplo n.º 4
0
void
StyleTask::markup( const Token &t )
{
  ComplexTask::markup(t);

   if (t.type() == START) {
      /*
       * Process Stylesheet start tags...
       */

      switch(t.olaf()){
       case OLAF::Stylesheet:

	 if (f_base >= 0) {
	    throw
	       (Unexpected
		("illegal nested STYLESHEET architectural form"));
	 }

	 f_base = t.level();
#ifdef FISH_DEBUG
	 DBUG_PRINT("Style", ("Style level=`%d'\n", f_base));
#endif
	 break;

       case OLAF::Path:

	 if ( f_pathbuf != NULL ) {
	    delete f_pathbuf;
	 }

	 f_pathbuf = new FlexBuffer();
	 f_buffer = f_pathbuf;
	 f_dataMode = inPath;
	 break;

       case OLAF::Select:
	 f_buffer->writeStr( "[" );
	 f_select = t.level();
	 break;
	
       case OLAF::Online:

	 f_buffer = onlineSS;
	 // feature_depth->clear();

	 if ( f_pathbuf == NULL ) {
	    throw(Unexpected("no path available for online feature."));
	 }

	 report_position(f_buffer, t.file(), t.line());
	 
	 f_buffer->writeStr( f_pathbuf->GetBuffer() );
	 f_buffer->writeStr( "\n" );
	 write_tabs( f_buffer, feature_depth, '\t');
	 f_buffer->writeStr( "{\n" );
	 feature_depth->push(t.level());

	 break;

       case OLAF::Print:

	 f_buffer = printSS;
	 // feature_depth->clear();

	 if ( f_pathbuf == NULL ) {
	    throw(Unexpected("no path available for print feature."));
	 }

	 report_position(f_buffer, t.file(), t.line());
	 f_buffer->writeStr( f_pathbuf->GetBuffer() );
	 f_buffer->writeStr( "\n" );
	 write_tabs( f_buffer, feature_depth, '\t');
	 f_buffer->writeStr( "{\n" );
	 feature_depth->push( t.level() );

	 break;

       case OLAF::AutoNumber:

	 report_position(onlineSS, t.file(), t.line());
	 autonumber(onlineSS, t);

	 report_position(printSS, t.file(), t.line());
	 autonumber(printSS, t);
	 break;
	
       case OLAF::FeatureText:

	 report_position(f_buffer, t.file(), t.line());
	 write_tabs( f_buffer, feature_depth, '\t');
	 
	 f_buffer->writeStr( t.giName() );
	 f_buffer->writeStr( ": " );
	 f_dataMode = startContent;
	 break;


      case OLAF::AutoRef:
	 {
	   const AttributeRec *arec;
	   int id = SGMLName::intern("ID");
	   if((arec = t.LookupAttr(id))){

	     if(f_dataMode == inContent){
	       f_buffer->writeStr(" + ");
	     }
	     
	     f_buffer->writeStr(arec->getAttrValueString());
	     f_dataMode = inContent;
	   } /* else document is not conforming... sgmls will report error */
	 }
	 break;
			       
       case OLAF::Feature:

	 report_position(f_buffer, t.file(), t.line());
	 write_tabs( f_buffer, feature_depth, '\t');
	 
	 f_buffer->writeStr( t.giName() );
	 f_buffer->writeStr( ": " );

	 const AttributeRec *arec;
   
	 /*
	  * Is it an enumeration feature?
	  */
	 if((arec = t.LookupAttr(OLAF::OL_Choice))){

           /* OL_Choice can only be applied to NAME attributes, hence
	      we don't neet to worryabout "'s in the attribute value.
	      */
	   /* except TRUE and FALSE....*/

	   const char *val = arec->getAttrValueString();

	   int quotes = !isdigit(val[0])
	     && strcmp(val, "TRUE") != 0
	     && strcmp(val, "FALSE") != 0
	     && val[0] != '@';

	   if (quotes) f_buffer->writeStr("\"");
	   f_buffer->writeStr(val);
	   if (quotes) f_buffer->writeStr("\" ");

	 }else{
	   f_buffer->writeStr( " {\n" );

	   for (arec = t.GetFirstAttr();
		arec != NULL;
		arec = t.GetNextAttr( arec )) {
	     
	     if (( arec->getAttrValueString() != NULL ) &&
		 ( arec->getAttrName() != OLAF::OLIAS )) {
	       
	       write_tabs( f_buffer, feature_depth, '\t');
	       f_buffer->put('\t');

	       write_attr(f_buffer, arec);

	       f_buffer->writeStr( ",\n" );
	     }
	   }
	   feature_depth->push(t.level());
	 }
	
	 break;
      }
      
      /*
       * first time we see OL-ID="...", spawn an OL_Data to collect the id
       */
      if ((f_base >= 0) && (f_locator == NULL) &&
          (t.LookupAttr(OLAF::OL_id))) {

#ifdef FISH_DEBUG
         DBUG_PRINT("Style", ("spawning locator collection subtask\n"));
#endif
         f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
         addSubTask( f_locator );

      }
   }

   else if (t.type() == END) {

      if (f_base > 0) {

	int topelement;
	if ( !feature_depth->empty() ) {
	  if ( (topelement = feature_depth->top()) ) {
	    if ( topelement == t.level() ) {
	      topelement = feature_depth->pop();
	      write_tabs( f_buffer, feature_depth, '\t');
	      
	      if(feature_depth->empty()){
		f_buffer->writeStr("}\n");
	      }
	      else {
		f_buffer->writeStr("},\n");
	      }

	    }else if ( topelement + 1 == t.level() ) {
	      /* need a new-line at end of FeatureText data */
	      f_buffer->writeStr(",\n");
	    }
	  }
	}
	  
	if (t.level() == f_base) {
	  /* found end of stylesheet... write out StyleSheet data */
#ifdef FISH_DEBUG
	  DBUG_PRINT("Style", ("found end of stylesheet write out StyleSheet data\n"));
#endif
	  write_record();
	  
	}
	else if(t.level() == f_select){
	  f_buffer->writeStr( "]" );
	  f_select = -1;
	}
      }
    }
}