2005-06-08 18:41:05 +04:00
|
|
|
%{
|
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
/*
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* 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))
|
|
|
|
|
2006-03-16 22:44:13 +03:00
|
|
|
/* 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
|
2005-06-13 17:59:48 +04:00
|
|
|
//#define YYMAXDEPTH 100000
|
|
|
|
//#define YYINITDEPTH 10000
|
2005-06-08 18:41:05 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Disable some warnings in the generated code. */
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
# pragma warn -8004 /* Variable assigned a value that is not used. */
|
2006-08-01 19:38:42 +04:00
|
|
|
# pragma warn -8008 /* condition always returns true */
|
|
|
|
# pragma warn -8060 /* possibly incorrect assignment */
|
|
|
|
# pragma warn -8066 /* unreachable code */
|
2005-06-08 18:41:05 +04:00
|
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning (disable: 4102) /* Unused goto label. */
|
2006-08-01 19:38:42 +04:00
|
|
|
# pragma warning (disable: 4065) /* Switch statement contains default but no
|
|
|
|
case. */
|
2005-06-08 18:41:05 +04:00
|
|
|
#endif
|
|
|
|
%}
|
|
|
|
|
|
|
|
/* Generate a reentrant parser object. */
|
|
|
|
%pure_parser
|
|
|
|
|
|
|
|
/*
|
|
|
|
%union {
|
|
|
|
char* string;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
/* Tokens */
|
|
|
|
%token cal_NCURLY
|
|
|
|
%token cal_DCURLY
|
2006-03-16 19:57:36 +03:00
|
|
|
%token cal_DOLLAR "$"
|
|
|
|
%token cal_LCURLY "{"
|
|
|
|
%token cal_RCURLY "}"
|
2005-06-08 18:41:05 +04:00
|
|
|
%token cal_NAME
|
2006-03-16 19:57:36 +03:00
|
|
|
%token cal_BSLASH "\\"
|
2005-06-08 18:41:05 +04:00
|
|
|
%token cal_SYMBOL
|
2006-03-16 19:57:36 +03:00
|
|
|
%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_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
|
|
|
{
|
2005-06-08 22:18:31 +04:00
|
|
|
$<str>$ = yyGetParser->ExpandVariable($<str>1);
|
2005-06-08 18:41:05 +04:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|