2004-08-31 13:49:56 +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.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-26 18:11:44 +04:00
|
|
|
#include "ompi_config.h"
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-10-26 18:11:44 +04:00
|
|
|
#if HAVE_UNISTD_H
|
2004-09-01 18:54:34 +04:00
|
|
|
#include <unistd.h>
|
2004-10-26 18:11:44 +04:00
|
|
|
#endif
|
2004-09-01 18:54:34 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
#include "mca/base/mca_base_parse_paramfile_lex.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local functions
|
|
|
|
*/
|
2004-09-05 20:05:37 +04:00
|
|
|
static int finish_parsing(void) ;
|
2004-08-31 13:49:56 +04:00
|
|
|
static int mca_base_yywrap(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* global variables
|
|
|
|
*/
|
|
|
|
int mca_base_yynewlines = 1;
|
|
|
|
bool mca_base_parse_done = false;
|
|
|
|
char *mca_base_string = NULL;
|
|
|
|
|
2004-09-05 20:05:37 +04:00
|
|
|
#define yyterminate() \
|
|
|
|
return finish_parsing()
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
%}
|
|
|
|
|
|
|
|
WHITE [\f\t\v ]
|
|
|
|
CHAR [A-Za-z0-9_\-\.]
|
|
|
|
|
|
|
|
%x VALUE
|
2005-08-02 02:25:47 +04:00
|
|
|
%x comment
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
{WHITE}*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
|
|
|
#.*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
2005-08-02 02:11:26 +04:00
|
|
|
"//".*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; }
|
2005-08-02 02:25:47 +04:00
|
|
|
|
|
|
|
"/*" { BEGIN(comment);
|
|
|
|
return MCA_BASE_PARSE_NEWLINE; }
|
|
|
|
<comment>[^*\n]* ; /* Eat up non '*'s */
|
|
|
|
<comment>"*"+[^*/\n]* ; /* Eat '*'s not followed by a '/' */
|
|
|
|
<comment>\n { mca_base_yynewlines++;
|
|
|
|
return MCA_BASE_PARSE_NEWLINE; }
|
|
|
|
<comment>"*"+"/" { BEGIN(INITIAL); /* Done with Block Comment */
|
|
|
|
return MCA_BASE_PARSE_NEWLINE; }
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
{WHITE}*"="{WHITE}* { BEGIN(VALUE); return MCA_BASE_PARSE_EQUAL; }
|
|
|
|
{WHITE}+ ; /* whitespace */
|
|
|
|
{CHAR}+ { return MCA_BASE_PARSE_SINGLE_WORD; }
|
|
|
|
|
2005-02-04 19:14:33 +03:00
|
|
|
<VALUE>{WHITE}*\n { BEGIN(INITIAL); return MCA_BASE_PARSE_NEWLINE; }
|
2005-10-13 02:49:23 +04:00
|
|
|
<VALUE>[^\n]*[^\t \n]/[\t ]* { return MCA_BASE_PARSE_VALUE; }
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
. { return MCA_BASE_PARSE_ERROR; }
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
|
2004-09-05 20:05:37 +04:00
|
|
|
/*
|
|
|
|
* This cleans up at the end of the parse (since, in this case, we
|
|
|
|
* always parse the entire file) and prevents a memory leak.
|
|
|
|
*/
|
|
|
|
static int finish_parsing(void)
|
2004-08-31 13:49:56 +04:00
|
|
|
{
|
2004-09-05 20:05:37 +04:00
|
|
|
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:47:14 +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-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
|
2004-10-15 15:42:54 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
static int mca_base_yywrap(void)
|
|
|
|
{
|
|
|
|
mca_base_parse_done = true;
|
|
|
|
return 1;
|
|
|
|
}
|
2004-10-15 15:42:54 +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 mca_base_param_init_buffer(FILE *file)
|
|
|
|
{
|
|
|
|
YY_BUFFER_STATE buf = yy_create_buffer(file, YY_BUF_SIZE);
|
|
|
|
yy_switch_to_buffer(buf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|