1
1

Convert this flex scanner to prefix all of its symbols with

"mca_llm_base_yy" so that we can have multiple flex scanners in one
library.

This commit was SVN r2407.
Этот коммит содержится в:
Jeff Squyres 2004-08-31 09:38:27 +00:00
родитель 639882b063
Коммит 1569ecdba3
5 изменённых файлов: 51 добавлений и 31 удалений

Просмотреть файл

@ -9,6 +9,8 @@ noinst_LTLIBRARIES = libmca_llm_base.la
# For VPATH builds, have to specify where static-modules.h will be found
AM_CPPFLAGS = -I$(top_builddir)/src
AM_LFLAGS = -Pmca_llm_base_yy
LEX_OUTPUT_ROOT = lex.mca_llm_base_yy
# Source code files

Просмотреть файл

@ -12,7 +12,7 @@
#include <stdlib.h>
extern int yylex(void);
extern FILE *yyin;
extern FILE *mca_llm_base_yyin;
int
main(int argc, char *argv[])
@ -24,9 +24,9 @@ main(int argc, char *argv[])
exit(1);
}
yyin = fopen(argv[1], "r");
mca_llm_base_yyin = fopen(argv[1], "r");
while (!mca_llm_base_parse_done) {
ret = yylex();
ret = mca_llm_base_yylex();
printf("%d: %s\n", ret, mca_llm_base_string);
}

Просмотреть файл

@ -22,7 +22,7 @@ static void
parse_error()
{
printf("hostfile: error reading hostfile at line %d, %s\n",
yynewlines, mca_llm_base_string);
mca_llm_base_yynewlines, mca_llm_base_string);
}
static
@ -44,13 +44,13 @@ parse_keyval(int first, ompi_rte_node_allocation_t *node)
}
/* find the equals */
if (MCA_LLM_BASE_EQUAL != yylex()) {
if (MCA_LLM_BASE_EQUAL != mca_llm_base_yylex()) {
free(key);
return OMPI_ERROR;
}
/* make sure we have a value */
val = yylex();
val = mca_llm_base_yylex();
if (MCA_LLM_BASE_STRING != val && MCA_LLM_BASE_QUOTED_STRING != val) {
free(key);
return OMPI_ERROR;
@ -79,9 +79,9 @@ int
parse_count(void)
{
/* find the equals */
if (MCA_LLM_BASE_EQUAL != yylex()) return -1;
if (MCA_LLM_BASE_EQUAL != mca_llm_base_yylex()) return -1;
/* and now the string */
if (MCA_LLM_BASE_STRING != yylex()) return -1;
if (MCA_LLM_BASE_STRING != mca_llm_base_yylex()) return -1;
return atoi(mca_llm_base_string);
}
@ -103,7 +103,7 @@ parse_line(int first, ompi_rte_node_allocation_t *node)
}
while (!mca_llm_base_parse_done) {
val = yylex();
val = mca_llm_base_yylex();
switch (val) {
case MCA_LLM_BASE_DONE:
return OMPI_SUCCESS;
@ -147,10 +147,10 @@ mca_llm_base_parse_hostfile(const char *hostfile)
list = OBJ_NEW(ompi_list_t);
mca_llm_base_parse_done = 0;
mca_llm_base_parse_done = false;
yyin = fopen(hostfile, "r");
if (NULL == yyin) {
mca_llm_base_yyin = fopen(hostfile, "r");
if (NULL == mca_llm_base_yyin) {
printf("hostfile: could not open %s\n", hostfile);
OBJ_RELEASE(list);
list = NULL;
@ -158,7 +158,7 @@ mca_llm_base_parse_hostfile(const char *hostfile)
}
while (!mca_llm_base_parse_done) {
val = yylex();
val = mca_llm_base_yylex();
switch (val) {
case MCA_LLM_BASE_DONE:
goto parse_exit;

Просмотреть файл

@ -5,14 +5,35 @@
#ifndef MCA_LLM_BASE_PARSE_HOSTFILE_LEX_H_
#define MCA_LLM_BASE_PARSE_HOSTFILE_LEX_H_
#include "ompi_config.h"
#ifdef malloc
#undef malloc
#endif
#ifdef realloc
#undef realloc
#endif
#ifdef free
#undef free
#endif
#include <stdio.h>
extern int yylex(void);
extern int mca_llm_base_yylex(void);
extern FILE *yyin;
extern int mca_llm_base_parse_done;
extern FILE *mca_llm_base_yyin;
extern bool mca_llm_base_parse_done;
extern char *mca_llm_base_string;
extern int yynewlines;
extern int mca_llm_base_yynewlines;
/*
* Make lex-generated files not issue compiler warnings
*/
#define YY_STACK_USED 0
#define YY_ALWAYS_INTERACTIVE 0
#define YY_NEVER_INTERACTIVE 0
#define YY_MAIN 0
#define YY_NO_UNPUT 1
#define MCA_LLM_BASE_DONE 0
#define MCA_LLM_BASE_ERROR 1

Просмотреть файл

@ -6,23 +6,23 @@
/*
* local functions
*/
static int yyerror(void);
int yywrap(void);
static int mca_llm_base_yyerror(void);
static int mca_llm_base_yywrap(void);
/*
* global variables
*/
int yynewlines=1;
int mca_llm_base_parse_done = 0;
int mca_llm_base_yynewlines=1;
bool mca_llm_base_parse_done = false;
char *mca_llm_base_string = NULL;
%}
%%
\n { yynewlines++; return MCA_LLM_BASE_NEWLINE; }
\n { mca_llm_base_yynewlines++; return MCA_LLM_BASE_NEWLINE; }
\"[^\"]*\" { mca_llm_base_string = yytext; return MCA_LLM_BASE_QUOTED_STRING; }
\"[^\"]*\" { mca_llm_base_string = yytext; return MCA_LLM_BASE_QUOTED_STRING; }
[\f\t\v ] ; /* whitespace */
@ -33,23 +33,20 @@ count { mca_llm_base_string = yytext; return MCA_LLM_BASE_COUNT; }
[A-Za-z0-9_\-\.]* { mca_llm_base_string = yytext; return MCA_LLM_BASE_STRING; }
. { mca_llm_base_string = yytext; return MCA_LLM_BASE_ERROR; }
. { mca_llm_base_string = yytext; return MCA_LLM_BASE_ERROR; }
%%
static
int
yyerror()
static int mca_llm_base_yyerror(void)
{
printf("%d: Invalid input (%s)\n", yynewlines, yytext);
printf("%d: Invalid input (%s)\n", mca_llm_base_yynewlines, yytext);
return MCA_LLM_BASE_ERROR;
}
int
yywrap()
static int mca_llm_base_yywrap(void)
{
mca_llm_base_parse_done = 1;
mca_llm_base_parse_done = true;
return 1;
}