CMake/Source/cmCommandArgumentParser.y

232 lines
4.4 KiB
Plaintext
Raw Normal View History

2005-06-08 18:41:05 +04:00
%{
Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
2016-09-27 22:01:08 +03:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2005-06-08 18:41:05 +04:00
/*
This file must be translated to C and modified to build everywhere.
Run bison like this:
bison --yacc --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y
Modify cmCommandArgumentParser.cxx:
- remove TABs
- remove use of the 'register' storage class specifier
- put header block at top of file
2005-06-08 18:41:05 +04:00
*/
2006-08-23 20:02:30 +04:00
#include "cmStandardIncludes.h"
2005-06-08 18:41:05 +04:00
/* Configure the parser to use a lexer object. */
#define YYPARSE_PARAM yyscanner
#define YYLEX_PARAM yyscanner
#define YYERROR_VERBOSE 1
#define cmCommandArgument_yyerror(x) \
cmCommandArgumentError(yyscanner, x)
#define yyGetParser (cmCommandArgument_yyget_extra(yyscanner))
/* Make sure malloc and free are available on QNX. */
#ifdef __QNX__
# include <malloc.h>
#endif
/* Make sure the parser uses standard memory allocation. The default
generated parser malloc/free declarations do not work on all
platforms. */
#include <stdlib.h>
#define YYMALLOC malloc
#define YYFREE free
2005-06-08 18:41:05 +04:00
/*-------------------------------------------------------------------------*/
#include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */
#include "cmCommandArgumentLexer.h" /* Interface to lexer object. */
#include "cmCommandArgumentParserTokens.h" /* Need YYSTYPE for YY_DECL. */
/* Forward declare the lexer entry point. */
YY_DECL;
/* Internal utility functions. */
static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
#define YYDEBUG 1
/* Configure the parser to support large input. */
#define YYMAXDEPTH 100000
#define YYINITDEPTH 10000
2005-06-08 18:41:05 +04:00
/* Disable some warnings in the generated code. */
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no
case. */
# pragma warning (disable: 4244) /* loss of precision */
# pragma warning (disable: 4702) /* unreachable code */
2005-06-08 18:41:05 +04:00
#endif
%}
/* Generate a reentrant parser object. */
%pure_parser
/*
%union {
char* string;
}
*/
/*-------------------------------------------------------------------------*/
/* Tokens */
%token cal_ENVCURLY
2005-06-08 18:41:05 +04:00
%token cal_NCURLY
%token cal_DCURLY
%token cal_DOLLAR "$"
%token cal_LCURLY "{"
%token cal_RCURLY "}"
2005-06-08 18:41:05 +04:00
%token cal_NAME
%token cal_BSLASH "\\"
2005-06-08 18:41:05 +04:00
%token cal_SYMBOL
%token cal_AT "@"
2005-06-08 18:41:05 +04:00
%token cal_ERROR
2005-06-08 22:18:31 +04:00
%token cal_ATNAME
2005-06-08 18:41:05 +04:00
/*-------------------------------------------------------------------------*/
/* grammar */
%%
Start:
2005-06-13 17:59:48 +04:00
GoalWithOptionalBackSlash
2005-06-08 18:41:05 +04:00
{
$<str>$ = 0;
yyGetParser->SetResult($<str>1);
}
2005-06-13 17:59:48 +04:00
GoalWithOptionalBackSlash:
Goal
2005-06-08 18:41:05 +04:00
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
Goal cal_BSLASH
2005-06-08 18:41:05 +04:00
{
2005-06-13 17:59:48 +04:00
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
2005-06-08 18:41:05 +04:00
}
2005-06-13 17:59:48 +04:00
Goal:
2005-06-08 18:41:05 +04:00
{
2005-06-13 17:59:48 +04:00
$<str>$ = 0;
2005-06-08 18:41:05 +04:00
}
|
2005-06-13 17:59:48 +04:00
String Goal
2005-06-08 18:41:05 +04:00
{
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
}
2005-06-13 17:59:48 +04:00
String:
OuterText
2005-06-08 18:41:05 +04:00
{
$<str>$ = $<str>1;
}
|
Variable
{
$<str>$ = $<str>1;
}
2005-06-13 17:59:48 +04:00
OuterText:
2005-06-08 18:41:05 +04:00
cal_NAME
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
cal_AT
2005-06-08 18:41:05 +04:00
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
cal_DOLLAR
2005-06-08 22:18:31 +04:00
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
cal_LCURLY
2005-06-08 22:18:31 +04:00
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
cal_RCURLY
2005-06-08 22:18:31 +04:00
{
$<str>$ = $<str>1;
}
|
2005-06-13 17:59:48 +04:00
cal_SYMBOL
2005-06-08 18:41:05 +04:00
{
$<str>$ = $<str>1;
}
Variable:
cal_ENVCURLY EnvVarName cal_RCURLY
{
$<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
//std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
}
|
2005-06-08 18:41:05 +04:00
cal_NCURLY MultipleIds cal_RCURLY
{
$<str>$ = yyGetParser->ExpandSpecialVariable($<str>1,$<str>2);
2005-06-08 22:18:31 +04:00
//std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
2005-06-08 18:41:05 +04:00
}
|
cal_DCURLY MultipleIds cal_RCURLY
{
$<str>$ = yyGetParser->ExpandVariable($<str>2);
2005-06-08 22:18:31 +04:00
//std::cerr << __LINE__ << " here: [" << $<str>1 << "] [" << $<str>2 << "] [" << $<str>3 << "]" << std::endl;
2005-06-08 18:41:05 +04:00
}
|
2005-06-08 22:18:31 +04:00
cal_ATNAME
2005-06-08 18:41:05 +04:00
{
$<str>$ = yyGetParser->ExpandVariableForAt($<str>1);
2005-06-08 18:41:05 +04:00
}
EnvVarName:
MultipleIds
{
$<str>$ = $<str>1;
}
|
cal_SYMBOL EnvVarName
{
$<str>$ = $<str>1;
}
2005-06-13 17:59:48 +04:00
MultipleIds:
{
2005-06-13 18:27:05 +04:00
$<str>$ = 0;
2005-06-13 17:59:48 +04:00
}
|
ID MultipleIds
{
$<str>$ = yyGetParser->CombineUnions($<str>1, $<str>2);
}
ID:
cal_NAME
{
$<str>$ = $<str>1;
}
|
Variable
{
$<str>$ = $<str>1;
}
2005-06-08 18:41:05 +04:00
%%
/* End of grammar */
/*--------------------------------------------------------------------------*/
void cmCommandArgumentError(yyscan_t yyscanner, const char* message)
{
yyGetParser->Error(message);
}