Ejemplo n.º 1
0
/*
 * inp_trimtaip
 *
 * grep data from input stream
 */
static u_long
inp_trimtaip(
	     parse_t      *parseio,
	     unsigned int  ch,
	     timestamp_t  *tstamp
	  )
{
	unsigned int rtc;
	
	parseprintf(DD_PARSE, ("inp_trimtaip(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
	
	switch (ch)
	{
	case '>':
		parseprintf(DD_PARSE, ("inp_trimptaip: START seen\n"));
		
		parseio->parse_index = 1;
		parseio->parse_data[0] = ch;
		parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
		return PARSE_INP_SKIP;
	  
	case '<':
		parseprintf(DD_PARSE, ("inp_trimtaip: END seen\n"));
		if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
			return parse_end(parseio);
		else
			return rtc;


	default:
		return parse_addchar(parseio, ch);
	}
}
Ejemplo n.º 2
0
/*
 * parse_inp_fnc_t inp_hopf6021
 *
 * grab data from input stream
 */
static u_long
inp_hopf6021(
	     parse_t      *parseio,
	     char         ch,
	     timestamp_t  *tstamp
	  )
{
	unsigned int rtc;

	parseprintf(DD_PARSE, ("inp_hopf6021(0x%p, 0x%x, ...)\n", (void*)parseio, ch));

	switch (ch)
	{
	case ETX:
		parseprintf(DD_PARSE, ("inp_hopf6021: EOL seen\n"));
		parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
		if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
			return parse_end(parseio);
		else
			return rtc;

	default:
		return parse_addchar(parseio, ch);
	}
}
Ejemplo n.º 3
0
static unsigned long
inp_sel240x( parse_t      *parseio,
	     char         ch,
	     timestamp_t  *tstamp
	   )
{
	unsigned long rc;

	parseprintf( DD_PARSE,
	             ("inp_sel240x(0x%lx, 0x%x, ...)\n",(long)parseio, ch));

	switch( ch )
	{
	case '\x01':
		parseio->parse_index = 1;
		parseio->parse_data[0] = ch;
		parseio->parse_dtime.parse_stime = *tstamp;
		rc = PARSE_INP_SKIP;
		break;
	case '\n':
		if( (rc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP )
		{
			rc = parse_end( parseio );
		}
		break;
	default:
		rc = parse_addchar( parseio, ch );
	}

	return rc;
}
Ejemplo n.º 4
0
/*
 * parse_inp_fnc_t inp_rcc8000
 *
 * grab data from input stream
 */
static u_long
inp_rcc8000(
	    parse_t      *parseio,
	    char         ch,
	    timestamp_t  *tstamp
	  )
{
	unsigned int rtc;

	parseprintf(DD_PARSE, ("inp_rcc8000(0x%p, 0x%x, ...)\n", (void*)parseio, ch));

	switch (ch)
	{
	case '\n':
		parseprintf(DD_PARSE, ("inp_rcc8000: EOL seen\n"));
		if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
			return parse_end(parseio);
		else
			return rtc;


	default:
		if (parseio->parse_index == 0) /* take sample at start of message */
		{
			parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
		}
		return parse_addchar(parseio, ch);
	}
}
Ejemplo n.º 5
0
/*
 * inp_dcf700
 *
 * grep data from input stream
 */
static u_long
inp_dcf7000(
	  parse_t      *parseio,
	  unsigned int  ch,
	  timestamp_t  *tstamp
	  )
{
	unsigned int rtc;
	
	parseprintf(DD_PARSE, ("inp_dcf7000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
	
	switch (ch)
	{
	case '\r':
		parseprintf(DD_PARSE, ("inp_dcf7000: EOL seen\n"));
		parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
		if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
			return parse_end(parseio);
		else
			return rtc;

	default:
		return parse_addchar(parseio, ch);
	}
}
Ejemplo n.º 6
0
/*
 * parse_inp_fnc_t mbg_input
 *
 * grab data from input stream
 */
static u_long
mbg_input(
	  parse_t      *parseio,
	  char         ch,
	  timestamp_t  *tstamp
	  )
{
	unsigned int rtc;

	parseprintf(DD_PARSE, ("mbg_input(0x%p, 0x%x, ...)\n", (void*)parseio, ch));

	switch (ch)
	{
	case STX:
		parseprintf(DD_PARSE, ("mbg_input: STX seen\n"));

		parseio->parse_index = 1;
		parseio->parse_data[0] = ch;
		parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
		return PARSE_INP_SKIP;

	case ETX:
		parseprintf(DD_PARSE, ("mbg_input: ETX seen\n"));
		if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
			return parse_end(parseio);
		else
			return rtc;

	default:
		return parse_addchar(parseio, ch);
	}
}
Ejemplo n.º 7
0
static int parse_node(xmlNodePtr node, simple_binary_t **otabxml)
{
    int status = 0;
    
    /* Call for the parser function of the node type. */
    switch (node->type) {
    case XML_ELEMENT_NODE:
	status = parse_element(node, otabxml);
	break;
    case XML_TEXT_NODE:
    case XML_COMMENT_NODE:
    case XML_PI_NODE:
	/* Text nodes, comments and PIs are ignored. */
	break;
	/*
	 * XML has also many other node types, these are not needed with 
	 * OTA. Therefore they are assumed to be an error.
	 */
    default:
	error(0, "OTA compiler: Unknown XML node in the OTA source.");
	return -1;
	break;
    }

    /* 
     * If node is an element with content, it will need an end tag after it's
     * children. The status for it is returned by parse_element.
     */
    switch (status) {
    case 0:

	if (node->children != NULL)
	    if (parse_node(node->children, otabxml) == -1)
		return -1;
	break;
    case 1:
	if (node->children != NULL)
	    if (parse_node(node->children, otabxml) == -1)
		return -1;
	parse_end(otabxml);
	break;

    case -1: /* Something went wrong in the parsing. */
	return -1;
    default:
	warning(0,"OTA compiler: undefined return value in a parse function.");
	return -1;
	break;
    }

    if (node->next != NULL)
	if (parse_node(node->next, otabxml) == -1)
	    return -1;

    return 0;
}
Ejemplo n.º 8
0
/*
 * Allocate a new device struct with device name filled in.  Will handle
 * finding the device on lines of the form:
 * <device foo=bar>devname</device>
 * <device>devname<foo>bar</foo></device>
 */
static int parse_dev(blkid_cache cache, blkid_dev *dev, char **cp)
{
	char *start, *tmp, *end, *name;
	int ret;

	if ((ret = parse_start(cp)) <= 0)
		return ret;

	start = tmp = strchr(*cp, '>');
	if (!start) {
		DBG(READ, ul_debug("blkid: short line parsing dev: %s", *cp));
		return -BLKID_ERR_CACHE;
	}
	start = skip_over_blank(start + 1);
	end = skip_over_word(start);

	DBG(READ, ul_debug("device should be %*s",
			       (int)(end - start), start));

	if (**cp == '>')
		*cp = end;
	else
		(*cp)++;

	*tmp = '\0';

	if (!(tmp = strrchr(end, '<')) || parse_end(&tmp) < 0) {
		DBG(READ, ul_debug("blkid: missing </device> ending: %s", end));
	} else if (tmp)
		*tmp = '\0';

	if (end - start <= 1) {
		DBG(READ, ul_debug("blkid: empty device name: %s", *cp));
		return -BLKID_ERR_CACHE;
	}

	name = strndup(start, end - start);
	if (name == NULL)
		return -BLKID_ERR_MEM;

	DBG(READ, ul_debug("found dev %s", name));

	if (!(*dev = blkid_get_dev(cache, name, BLKID_DEV_CREATE))) {
		free(name);
		return -BLKID_ERR_MEM;
	}

	free(name);
	return 1;
}
Ejemplo n.º 9
0
Archivo: parser.c Proyecto: rju/slp
/* parser and renderer for nested frames which use grouping
 */
int parse_frame_body_loop (const int subslide) {
	while (token != EOF) {
		switch (token) {
		case STRUCT:
			if (!parse_structure()) return 0;
			break;
		case IMAGE:
			if (!parse_figure()) return 0;
			break;
		case ANIMATION:
			if (!parse_animation()) return 0;
			break;
		case LISTING:
			if (!parse_listing()) return 0;
			break;
		case ITEM:
			if (!parse_item(1,item_type)) return 0;
			break;
		case URL:
			if (!parse_url()) return 0;
			break;
		case COLUMN:
			if (parse_column() == -1) return 0;
			break;
		case COLUMN_SEP:
			if (parse_column_sep() == -1) return 0;
			break;
		case END:
			if (parse_end() == -1) return 0;
			break;
		case CURLY_C_BRACE:
			return 1;
		case VALUE:
			// mirror value to output
			fprintf(ofile,"%s",string);
			token = yylex();
			break;
		case NEWLINE: // ignore empty newline
			token = yylex();
			break;
		default:
			fprintf(stderr, "<%s:%d> [%d] Frame mode: illegal token %s found.\n", 
				__FILE__,__LINE__,yylineno, get_token_name(token));
			fprintf(stderr, "Expected commands: uncover (+), overlay (#), only (~), structure ('), image, listing, item or URL\n");
			fprintf(stderr, "\tor end frame mode with: New frame, section, title, author, date or an end of file\n");
			return 0;
		}
	}
	return 1;
}
Ejemplo n.º 10
0
/*
** include_hsc
**
** read from inpf, parse for hsc-commands and execute them,
** check for html-error,
** write all out to outf and close input file.
**
** params: inpfnm...input file name
**         outf.....output file structure, already opended
**
** result: TRUE, if all worked well, else FALSE
*/
BOOL include_hsc( STRPTR inpfnm, FILE *outf, ULONG optn )
{

    INFILE *inpf  = NULL;  /* input file */
    BOOL    ok;            /* result */

    inpf = infopen( inpfnm, MAXLINELEN );        /* open input file */
    ok   = (inpf!=NULL);

    if ( inpf ) {                                /* file opened? */

        while ( !infeof(inpf) && ok ) {          /*    parse file */

            if ( !(optn & IH_PARSE_MACRO) )
                status_infile( inpf, FALSE );    /*    status message */
            ok = parse_hsc( inpf );
        }

        if ( ok && (optn & IH_PARSE_END) ) {     /*    parse end */
                                                 /*    (unclosed tags etc) */
            ok = parse_end( inpf );

        }

        /* end of file status */
        if ( !(optn & IH_PARSE_MACRO) ) {

            status_infile( inpf, TRUE );         /*    status message */
            status_lf();                         /*    (display num of line) */

        }

        infclose( inpf );                        /*    close file */
                                                 
    } else {                                     /* N-> error message */

        message( ERROR_FILE_OPEN, NULL );
        errstr( "can not open " );
        errqstr( inpfnm );
        errstr( " for input: " );
        errstr( strerror( errno ) );
        errlf();
        ok = FALSE;
    }

    return ( ok );
}
Ejemplo n.º 11
0
void
catalog_reader_parse (abstract_catalog_reader_ty *pop, FILE *fp,
                      const char *real_filename, const char *logical_filename,
                      catalog_input_format_ty input_syntax)
{
  error_message_count = 0;

  /* Parse the stream's content.  */
  parse_start (pop);
  input_syntax->parse (pop, fp, real_filename, logical_filename);
  parse_end (pop);

  if (error_message_count > 0)
    po_xerror (PO_SEVERITY_FATAL_ERROR, NULL,
               /*real_filename*/ NULL, (size_t)(-1), (size_t)(-1), false,
               xasprintf (ngettext ("found %d fatal error",
                                    "found %d fatal errors",
                                    error_message_count),
                          error_message_count));
}
Ejemplo n.º 12
0
/*
 * Parse an element node. Check if there is a token for an element tag; if not
 * output the element as a string, else ouput the token. After that, call 
 * attribute parsing functions
 * Returns:      1, add an end tag (element node has no children)
 *               0, do not add an end tag (it has children)
 *              -1, an error occurred
 */
static int parse_element(xmlNodePtr node, simple_binary_t **sibxml)
{
    Octstr *name,
           *outos;
    size_t i;
    unsigned char status_bits,
             si_hex;
    int add_end_tag;
    xmlAttrPtr attribute;

    name = octstr_create((char *)node->name);
    outos = NULL;
    if (octstr_len(name) == 0) {
        octstr_destroy(name);
        return -1;
    }

    i = 0;
    while (i < NUMBER_OF_ELEMENTS) {
        if (octstr_compare(name, octstr_imm(si_elements[i].name)) == 0)
            break;
        ++i;
    }

    status_bits = 0x00;
    si_hex = 0x00;
    add_end_tag = 0;

    if (i != NUMBER_OF_ELEMENTS) {
        si_hex = si_elements[i].token;
        if ((status_bits = element_check_content(node)) > 0) {
	    si_hex = si_hex | status_bits;
	    
	    if ((status_bits & WBXML_CONTENT_BIT) == WBXML_CONTENT_BIT)
	        add_end_tag = 1;
        }
        output_char(si_hex, sibxml);
    } else {
        warning(0, "unknown tag %s in SI source", octstr_get_cstr(name));
        si_hex = WBXML_LITERAL;
        if ((status_bits = element_check_content(node)) > 0) {
	    si_hex = si_hex | status_bits;
	    /* If this node has children, the end tag must be added after 
	       them. */
	    if ((status_bits & WBXML_CONTENT_BIT) == WBXML_CONTENT_BIT)
		add_end_tag = 1;
	}
	output_char(si_hex, sibxml);
        output_octet_string(outos = octstr_duplicate(name), sibxml);
    }

    if (node->properties != NULL) {
	attribute = node->properties;
	while (attribute != NULL) {
	    parse_attribute(attribute, sibxml);
	    attribute = attribute->next;
	}
	parse_end(sibxml);
    }

    octstr_destroy(outos);
    octstr_destroy(name);
    return add_end_tag;
}
Ejemplo n.º 13
0
token_t *tokenize(char *buf)
{
	token_t *tokens = (token_t *)malloc(sizeof(token_t) * TOKENSIZE);
	token_t *head = tokens;

	while (*buf != '\n') {
		buf = skip_space(buf);
		char c = *buf;

		switch (c) {
		case '(' :
			*tokens = parse_begin(buf);
			tokens++;
			break;

		case ')' :
			*tokens = parse_end(buf);
			tokens++;
			break;

		case '+' :
		case '-' :
			if(isalnum(*(buf+1)))
				goto number;

		case '*' :
		case '/' :
		case '=' :
		case '<' :
		case '>' :
			*tokens = parse_operater(buf);
			tokens++;
			break;

		case '0' :
		case '1' :
		case '2' :
		case '3' :
		case '4' :
		case '5' :
		case '6' :
		case '7' :
		case '8' :
		case '9' :
number:     *tokens = parse_number(buf);
			tokens++;
			while(isalnum(*buf)){
				buf++;
			}
			buf-=1;
			break;

		default:
			*tokens = parse_symbol(buf);
			tokens++;
			while(isalpha(*buf)){
				buf++;
			}
			buf-=1;
			break;
		}
		buf++;
	}
	return head;
}
Ejemplo n.º 14
0
static u_long 
inp_varitext(
	     parse_t	 *parseio,
	     unsigned int ch,
	     timestamp_t *tstamp
	     )
{
  struct varitext *t = (struct varitext *)parseio->parse_pdata;
  int    rtc;

  parseprintf(DD_PARSE, ("inp_varitext(0x%lx, 0x%x, ...)\n", (long)parseio, ch));

  if (!t) 
    return PARSE_INP_SKIP;	/* local data not allocated - sigh! */

  if (ch == 'T') 
    t->tstamp = *tstamp;

  if ((t->previous_ch == 'T') && (ch == ':'))
    {
      parseprintf(DD_PARSE, ("inp_varitext: START seen\n"));

      parseio->parse_data[0] = 'T';
      parseio->parse_index=1;
      parseio->parse_dtime.parse_stime = t->tstamp; /* Time stamp at packet start */
      t->start_found = 1;
      t->end_found = 0;
      t->end_count = 0;
    }

  if (t->start_found)
    {
      if ((rtc = parse_addchar(parseio, ch)) != PARSE_INP_SKIP)
	{
	  parseprintf(DD_PARSE, ("inp_varitext: ABORTED due to too many characters\n"));

	  memset(t, 0, sizeof(struct varitext));
	  return rtc;
	}

      if (t->end_found) 
	{
	  if (++(t->end_count) == 4) /* Finally found the end of the message */
	    {
	      parseprintf(DD_PARSE, ("inp_varitext: END seen\n"));

	      memset(t, 0, sizeof(struct varitext));
	      if ((rtc = parse_addchar(parseio, 0)) == PARSE_INP_SKIP)
		return parse_end(parseio);
	      else
		return rtc;
	    }	
	}

      if ((t->previous_ch == '\r') && (ch == '\n')) 
	{
	  t->end_found = 1;
	}

    }
 
  t->previous_ch = ch;

  return PARSE_INP_SKIP;
}
Ejemplo n.º 15
0
static char*
parse_buf(pTHX_ PSTATE* p_state, char *beg, char *end, U32 utf8, SV* self)
{
    char *s = beg;
    char *t = beg;
    char *new_pos;

    while (!p_state->eof) {
	/*
	 * At the start of this loop we will always be ready for eating text
	 * or a new tag.  We will never be inside some tag.  The 't' points
	 * to where we started and the 's' is advanced as we go.
	 */

	while (p_state->literal_mode) {
	    char *l = p_state->literal_mode;
	    bool skip_quoted_end = (strEQ(l, "script") || strEQ(l, "style"));
	    char inside_quote = 0;
	    bool escape_next = 0;
	    char *end_text;

	    while (s < end) {
		if (*s == '<' && !inside_quote)
		    break;
		if (skip_quoted_end) {
		    if (escape_next) {
			escape_next = 0;
		    }
		    else {
			if (*s == '\\')
			    escape_next = 1;
			else if (inside_quote && *s == inside_quote)
			    inside_quote = 0;
			else if (*s == '\r' || *s == '\n')
			    inside_quote = 0;
			else if (!inside_quote && (*s == '"' || *s == '\''))
			    inside_quote = *s;
		    }
		}
		s++;
	    }

	    if (s == end) {
		s = t;
		goto DONE;
	    }

	    end_text = s;
	    s++;
      
	    /* here we rely on '\0' termination of perl svpv buffers */
	    if (*s == '/') {
		s++;
		while (*l && toLOWER(*s) == *l) {
		    s++;
		    l++;
		}

		if (!*l && (strNE(p_state->literal_mode, "plaintext") || p_state->closing_plaintext)) {
		    /* matched it all */
		    token_pos_t end_token;
		    end_token.beg = end_text + 2;
		    end_token.end = s;

		    while (isHSPACE(*s))
			s++;
		    if (*s == '>') {
			s++;
			if (t != end_text)
			    report_event(p_state, E_TEXT, t, end_text, utf8,
					 0, 0, self);
			report_event(p_state, E_END,  end_text, s, utf8,
				     &end_token, 1, self);
			p_state->literal_mode = 0;
			p_state->is_cdata = 0;
			t = s;
		    }
		}
	    }
	}

#ifdef MARKED_SECTION
	while (p_state->ms == MS_CDATA || p_state->ms == MS_RCDATA) {
	    while (s < end && *s != ']')
		s++;
	    if (*s == ']') {
		char *end_text = s;
		s++;
		if (*s == ']') {
		    s++;
		    if (*s == '>') {
			s++;
			/* marked section end */
			if (t != end_text)
			    report_event(p_state, E_TEXT, t, end_text, utf8,
					 0, 0, self);
			report_event(p_state, E_NONE, end_text, s, utf8, 0, 0, self);
			t = s;
			SvREFCNT_dec(av_pop(p_state->ms_stack));
			marked_section_update(p_state);
			continue;
		    }
		}
	    }
	    if (s == end) {
		s = t;
		goto DONE;
	    }
	}
#endif

	/* first we try to match as much text as possible */
	while (s < end && *s != '<') {
#ifdef MARKED_SECTION
	    if (p_state->ms && *s == ']') {
		char *end_text = s;
		s++;
		if (*s == ']') {
		    s++;
		    if (*s == '>') {
			s++;
			report_event(p_state, E_TEXT, t, end_text, utf8,
				     0, 0, self);
			report_event(p_state, E_NONE, end_text, s, utf8,
				     0, 0, self);
			t = s;
			SvREFCNT_dec(av_pop(p_state->ms_stack));
			marked_section_update(p_state);    
			continue;
		    }
		}
	    }
#endif
	    s++;
	}
	if (s != t) {
	    if (*s == '<') {
		report_event(p_state, E_TEXT, t, s, utf8, 0, 0, self);
		t = s;
	    }
	    else {
		s--;
		if (isHSPACE(*s)) {
		    /* wait with white space at end */
		    while (s >= t && isHSPACE(*s))
			s--;
		}
		else {
		    /* might be a chopped up entities/words */
		    while (s >= t && !isHSPACE(*s))
			s--;
		    while (s >= t && isHSPACE(*s))
			s--;
		}
		s++;
		if (s != t)
		    report_event(p_state, E_TEXT, t, s, utf8, 0, 0, self);
		break;
	    }
	}

	if (end - s < 3)
	    break;

	/* next char is known to be '<' and pointed to by 't' as well as 's' */
	s++;

#ifdef USE_PFUNC
	new_pos = parsefunc[(unsigned char)*s](p_state, t, end, utf8, self);
#else
	if (isHNAME_FIRST(*s))
	    new_pos = parse_start(p_state, t, end, utf8, self);
	else if (*s == '/')
	    new_pos = parse_end(p_state, t, end, utf8, self);
	else if (*s == '!')
	    new_pos = parse_decl(p_state, t, end, utf8, self);
	else if (*s == '?')
	    new_pos = parse_process(p_state, t, end, utf8, self);
	else
	    new_pos = 0;
#endif /* USE_PFUNC */

	if (new_pos) {
	    if (new_pos == t) {
		/* no progress, need more data to know what it is */
		s = t;
		break;
	    }
	    t = s = new_pos;
	}

	/* if we get out here then this was not a conforming tag, so
	 * treat it is plain text at the top of the loop again (we
	 * have already skipped past the "<").
	 */
    }

DONE:
    return s;

}
Ejemplo n.º 16
0
int lex (char *buf, arff_info_t * info)
{
	char *tok;
	char c;
	int i, r;
	token_t delimiter;

	for (;;) {
		if ((c = *buf++) == '\0')
			break;

		switch (c) {
		case ' ':
		case '\t':
		case '\r':
			// ignore
			break;
		case '%':
			/* a comment */
			do {
				c = *buf++;
			} while ((c != '\n') && (c != '\0'));
			buf--;
			break;
		case '\n':
			/* a new line */
			TRY (r, parse (TOKEN_NEWLINE, NULL, info));
			break;
		case ',':
			/* a comma */
			TRY (r, parse (TOKEN_COMMA, NULL, info));
			break;
		case '{':
			/* a left brace */
			TRY (r, parse (TOKEN_LEFTBRACE, NULL, info));
			break;
		case '}':
			/* a right brace */
			TRY (r, parse (TOKEN_RIGHTBRACE, NULL, info));
			break;
		default:
			/* something else */
			buf--;
			tok = read_token (&buf, &delimiter);

			/* check if it is a special token */
			for (i = 0; special[i].string != NULL; i++) {
				if (!stricmp (tok, special[i].string)) {
					TRY (r,
					     parse (special[i].type, tok,
						    info));
					break;
				}
			}
			if (special[i].string == NULL)
				TRY (r, parse (TOKEN_TOKEN, tok, info));
			if (delimiter < TOKEN_NUM_TYPES)
				TRY (r, parse (delimiter, NULL, info));
			break;
		}
	}

	parse_end (info);

	return 0;
}
Ejemplo n.º 17
0
Archivo: parser.c Proyecto: rju/slp
/*
 * parse the content of a frame
 */
int parse_frame() {
	int subslide = 1;

	structure_count = 0;

	fprintf(ofile,"%% FRAME\n");
	fprintf(ofile,"\\begin{frame}[fragile]\n");

	if ((token = yylex()) == VALUE) {
		fprintf(ofile,"\\frametitle{%s}\n", string);
		token = yylex();
		while (token != EOF) {
			switch (token) {
			case SUBTITLE:
				if (!parse_subtitle()) return 0;
				break;
			case UNCOVER:
				if (!parse_frame_body("uncover",subslide++)) return 0;
				break;
			case OVERLAY:
				if (!parse_frame_body("overlay",subslide++)) return 0;
				break;
			case ONLY:
				if (!parse_frame_body("only",subslide++)) return 0;
				break;
			case STRUCT:
				if (!parse_structure()) return 0;
				break;
			case IMAGE:
				if (!parse_figure()) return 0;
				break;
			case ANIMATION:
				if (!parse_animation()) return 0;
				break;
			case LISTING:
				if (!parse_listing()) return 0;
				break;
			case ITEM:
				if (!parse_item(1,item_type)) return 0;
				break;
			case URL:
				if (!parse_url()) return 0;
				break;
			case COPY:
				if (!parse_copy()) return 0;
				break;
			case COLUMN:
				if (parse_column() == -1) return 0;
				break;
			case COLUMN_SEP:
				if (parse_column_sep() == -1) return 0;
				break;
			case END:
				if (parse_end() == -1) return 0;
				break;
			case VALUE:
				// mirror value to output
				fprintf(ofile,"%s",string);
				token = yylex();
				break;
			case FRAME:
			case SECTION:
			case TITLE:
			case AUTHOR:
			case DATE:
			case ZERO:
			case PART:
				fprintf(ofile,"\\end{frame}\n\n");
				return 1;
			case NEWLINE: // ignore empty newline
				token = yylex();
				break;
			default:
				fprintf(stderr, "<%s:%d> [%d] Frame mode: illegal token %s found.\n", 
					__FILE__,__LINE__,yylineno, get_token_name(token));
				fprintf(stderr, "Expected commands: uncover (+), overlay (#), only (~), structure ('), image, listing, item or URL\n");
				fprintf(stderr, "\tor end frame mode with: New frame, section, title, author, date or an end of file\n");
				return 0;
			}
		}
		return 1;
	} else {
		fprintf(stderr, "<%s:%d> [%d] Frame mode: expected value, but %s found.\n", __FILE__,__LINE__, yylineno, get_token_name(token));
		return 0;
	}
}