You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
3.7 KiB
140 lines
3.7 KiB
16 years ago
|
%{
|
||
8 years ago
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||
16 years ago
|
/*
|
||
|
|
||
8 years ago
|
This file must be translated to C++ and modified to build everywhere.
|
||
16 years ago
|
|
||
8 years ago
|
Run flex >= 2.6 like this:
|
||
16 years ago
|
|
||
8 years ago
|
flex --nounistd -DFLEXINT_H --prefix=cmCommandArgument_yy --header-file=cmCommandArgumentLexer.h -ocmCommandArgumentLexer.cxx cmCommandArgumentLexer.in.l
|
||
16 years ago
|
|
||
|
Modify cmCommandArgumentLexer.cxx:
|
||
8 years ago
|
- remove trailing whitespace: sed -i 's/\s*$//' cmCommandArgumentLexer.h cmCommandArgumentLexer.cxx
|
||
|
- remove blank lines at end of file
|
||
|
- #include "cmStandardLexer.h" at the top
|
||
|
- add cast in yy_scan_bytes for loop condition of _yybytes_len to size_t
|
||
16 years ago
|
|
||
|
*/
|
||
|
|
||
8 years ago
|
/* IWYU pragma: no_forward_declare yyguts_t */
|
||
16 years ago
|
|
||
|
#include "cmCommandArgumentParserHelper.h"
|
||
|
|
||
|
/* Replace the lexer input function. */
|
||
|
#undef YY_INPUT
|
||
|
#define YY_INPUT(buf, result, max_size) \
|
||
|
{ result = yyextra->LexInput(buf, max_size); }
|
||
|
|
||
|
/* Include the set of tokens from the parser. */
|
||
|
#include "cmCommandArgumentParserTokens.h"
|
||
|
|
||
|
/*--------------------------------------------------------------------------*/
|
||
|
%}
|
||
|
|
||
|
%option reentrant
|
||
|
%option noyywrap
|
||
16 years ago
|
%option nounput
|
||
16 years ago
|
%pointer
|
||
|
%s ESCAPES
|
||
|
%s NOESCAPES
|
||
|
|
||
|
%%
|
||
|
|
||
16 years ago
|
\$ENV\{ {
|
||
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
|
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
|
||
|
return cal_ENVCURLY;
|
||
|
}
|
||
|
|
||
12 years ago
|
\$[A-Za-z0-9/_.+-]+\{ {
|
||
16 years ago
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
|
||
|
return cal_NCURLY;
|
||
|
}
|
||
16 years ago
|
|
||
12 years ago
|
@[A-Za-z0-9/_.+-]+@ {
|
||
16 years ago
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2);
|
||
|
return cal_ATNAME;
|
||
|
}
|
||
16 years ago
|
|
||
|
"${" {
|
||
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->DCURLYVariable;
|
||
|
return cal_DCURLY;
|
||
|
}
|
||
|
|
||
|
"}" {
|
||
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->RCURLYVariable;
|
||
|
return cal_RCURLY;
|
||
|
}
|
||
|
|
||
|
"@" {
|
||
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->ATVariable;
|
||
|
return cal_AT;
|
||
|
}
|
||
|
|
||
12 years ago
|
[A-Za-z0-9/_.+-]+ {
|
||
16 years ago
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
|
return cal_NAME;
|
||
16 years ago
|
}
|
||
|
|
||
|
<ESCAPES>\\. {
|
||
|
if ( !yyextra->HandleEscapeSymbol(yylvalp, *(yytext+1)) )
|
||
|
{
|
||
|
return cal_ERROR;
|
||
|
}
|
||
12 years ago
|
return cal_SYMBOL;
|
||
16 years ago
|
}
|
||
|
|
||
12 years ago
|
[^\${}\\@]+ {
|
||
16 years ago
|
//std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl;
|
||
12 years ago
|
yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
|
return cal_SYMBOL;
|
||
16 years ago
|
}
|
||
|
|
||
|
"$" {
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->DOLLARVariable;
|
||
12 years ago
|
return cal_DOLLAR;
|
||
16 years ago
|
}
|
||
|
|
||
|
"{" {
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->LCURLYVariable;
|
||
12 years ago
|
return cal_LCURLY;
|
||
16 years ago
|
}
|
||
|
|
||
|
<ESCAPES>"\\" {
|
||
12 years ago
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
16 years ago
|
yylvalp->str = yyextra->BSLASHVariable;
|
||
12 years ago
|
return cal_BSLASH;
|
||
16 years ago
|
}
|
||
|
|
||
|
<NOESCAPES>"\\" {
|
||
|
//yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext));
|
||
|
yylvalp->str = yyextra->BSLASHVariable;
|
||
|
return cal_SYMBOL;
|
||
|
}
|
||
|
|
||
|
%%
|
||
|
|
||
|
/*--------------------------------------------------------------------------*/
|
||
|
void cmCommandArgument_SetupEscapes(yyscan_t yyscanner, bool noEscapes)
|
||
|
{
|
||
|
/* Hack into the internal flex-generated scanner to set the state. */
|
||
|
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
|
||
8 years ago
|
if(noEscapes) {
|
||
16 years ago
|
BEGIN(NOESCAPES);
|
||
8 years ago
|
} else {
|
||
16 years ago
|
BEGIN(ESCAPES);
|
||
8 years ago
|
}
|
||
16 years ago
|
}
|