2004-09-05 20:05:37 +04:00
|
|
|
%{ /* -*- C -*- */
|
2004-11-22 03:37:56 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
2004-09-05 20:05:37 +04:00
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-10-26 18:11:44 +04:00
|
|
|
#if HAVE_UNISTD_H
|
2004-09-05 20:05:37 +04:00
|
|
|
#include <unistd.h>
|
2004-10-26 18:11:44 +04:00
|
|
|
#endif
|
2004-09-05 20:05:37 +04:00
|
|
|
|
|
|
|
#include "util/show_help_lex.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* public functions
|
|
|
|
*/
|
|
|
|
int ompi_show_help_finish_parsing(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local functions
|
|
|
|
*/
|
2004-10-18 19:38:19 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
static int ompi_show_help_yywrap(void);
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2004-09-05 20:05:37 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* global variables
|
|
|
|
*/
|
|
|
|
int ompi_show_help_yynewlines = 1;
|
|
|
|
bool ompi_show_help_parse_done = false;
|
|
|
|
char *ompi_show_help_string = NULL;
|
|
|
|
|
|
|
|
#define yyterminate() \
|
|
|
|
return ompi_show_help_finish_parsing()
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
WHITE [\f\t\v ]
|
|
|
|
CHAR [A-Za-z0-9_\-\.]
|
|
|
|
|
|
|
|
%x CHOMP
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
#.*\n ; /* comment line */
|
|
|
|
|
|
|
|
^\[.+\]/.*\n { BEGIN(CHOMP); return OMPI_SHOW_HELP_PARSE_TOPIC; }
|
|
|
|
|
|
|
|
<CHOMP>.*\n { BEGIN(INITIAL); }
|
|
|
|
|
|
|
|
.*/\n { BEGIN(CHOMP); return OMPI_SHOW_HELP_PARSE_MESSAGE; }
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This cleans up at the end of the parse (since, in this case, we
|
|
|
|
* always parse the entire file) and prevents a memory leak.
|
|
|
|
*/
|
|
|
|
int ompi_show_help_finish_parsing(void)
|
|
|
|
{
|
|
|
|
if (NULL != YY_CURRENT_BUFFER) {
|
|
|
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
2004-09-16 13:14:01 +04:00
|
|
|
#if defined(YY_CURRENT_BUFFER_LVALUE)
|
2004-09-16 12:48:31 +04:00
|
|
|
YY_CURRENT_BUFFER_LVALUE = NULL;
|
2004-09-16 13:14:01 +04:00
|
|
|
#else
|
|
|
|
YY_CURRENT_BUFFER = NULL;
|
|
|
|
#endif /* YY_CURRENT_BUFFER_LVALUE */
|
2004-09-05 20:05:37 +04:00
|
|
|
}
|
|
|
|
return YY_NULL;
|
|
|
|
}
|
|
|
|
|
2004-10-16 01:38:42 +04:00
|
|
|
|
2004-09-05 20:05:37 +04:00
|
|
|
static int ompi_show_help_yywrap(void)
|
|
|
|
{
|
|
|
|
ompi_show_help_parse_done = true;
|
|
|
|
return 1;
|
|
|
|
}
|
2004-10-16 01:38:42 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ensure that we have a valid yybuffer to use. Specifically, if this
|
|
|
|
* scanner is invoked a second time, finish_parsing() (above) will
|
|
|
|
* have been executed, and the current buffer will have been freed.
|
|
|
|
* Flex doesn't recognize this fact because as far as it's concerned,
|
|
|
|
* its internal state was already initialized, so it thinks it should
|
|
|
|
* have a valid buffer. Hence, here we ensure to give it a valid
|
|
|
|
* buffer.
|
|
|
|
*/
|
|
|
|
int ompi_show_help_init_buffer(FILE *file)
|
|
|
|
{
|
|
|
|
YY_BUFFER_STATE buf = yy_create_buffer(file, YY_BUF_SIZE);
|
|
|
|
yy_switch_to_buffer(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|