MCPcopy Create free account
hub / github.com/Genivia/RE-flex / write_class

Method write_class

src/reflex.cpp:1953–2307  ·  view source on GitHub ↗

Write the lexer class to lex.yy.cpp

Source from the content-addressed store, hash-verified

1951
1952/// Write the lexer class to lex.yy.cpp
1953void Reflex::write_class()
1954{
1955 if (!out->good())
1956 return;
1957 write_banner("REGEX MATCHER");
1958 if (!options["noindent"].empty())
1959 *out << "#define WITH_NO_INDENT\n";
1960 *out << "#include <" << library->file << ">\n";
1961 const char *matcher = library->matcher;
1962 std::string lex = options["lex"];
1963 std::string token_type = options["token_type"].empty() ? "int" : options["token_type"];
1964 std::string yyltype = options["YYLTYPE"].empty() ? "YYLTYPE" : options["YYLTYPE"];
1965 std::string yystype = options["YYSTYPE"].empty() ? "YYSTYPE" : options["YYSTYPE"];
1966 std::string params = options["params"].empty() ? "void" : options["params"];
1967 std::string comma_params = options["params"].empty() ? "" : ", " + params;
1968 std::string args = options["params"].empty() ? "" : param_args(params);
1969 std::string comma_args = options["params"].empty() ? "" : ", " + args;
1970 std::string base;
1971 if (!options["flex"].empty())
1972 {
1973 write_banner("FLEX-COMPATIBLE ABSTRACT LEXER CLASS");
1974 *out << "#include <reflex/flexlexer.h>\n";
1975 if (!options["namespace"].empty())
1976 {
1977 *out << '\n';
1978 write_namespace_open();
1979 *out << '\n';
1980 }
1981 *out << "typedef reflex::FlexLexer" << "<" << matcher << "> FlexLexer;\n";
1982 if (!options["namespace"].empty())
1983 {
1984 *out << '\n';
1985 write_namespace_close();
1986 }
1987 base = "FlexLexer";
1988 if (options["bison_cc"].empty() && (!options["bison"].empty() || !options["bison_locations"].empty()) && options["reentrant"].empty() && options["bison_bridge"].empty())
1989 {
1990 if (!options["yy"].empty())
1991 *out <<
1992 "#undef yyin\n"
1993 "#undef yyout\n";
1994 *out <<
1995 "#undef yytext\n"
1996 "#undef yyleng\n"
1997 "#undef yylineno\n";
1998 }
1999 }
2000 else
2001 {
2002 write_banner("ABSTRACT LEXER CLASS");
2003 *out << "#include <reflex/abslexer.h>\n";
2004 base.assign("reflex::AbstractLexer<").append(matcher).append(">");
2005 }
2006 write_banner("LEXER CLASS");
2007 std::string lexer = options["lexer"];
2008 if (!options["namespace"].empty())
2009 {
2010 write_namespace_open();

Callers

nothing calls this directly

Calls 4

assignMethod · 0.80
goodMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected