%{ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ /* This file must be translated to C and modified to build everywhere. Run bison like this: bison --name-prefix=cmCommandArgument_yy --defines=cmCommandArgumentParserTokens.h -ocmCommandArgumentParser.cxx cmCommandArgumentParser.y */ #include "cmConfigure.h" // IWYU pragma: keep #include #define yyGetParser (cmCommandArgument_yyget_extra(yyscanner)) /* Make sure malloc and free are available on QNX. */ #ifdef __QNX__ # include #endif #include /* Make sure the parser uses standard memory allocation. The default generated parser malloc/free declarations do not work on all platforms. */ #include #define YYMALLOC malloc #define YYFREE free /*-------------------------------------------------------------------------*/ #include "cmCommandArgumentParserHelper.h" /* Interface to parser object. */ #include "cmCommandArgumentLexer.h" /* Interface to lexer object. */ /* Forward declare the lexer entry point. */ YY_DECL; /* Helper function to forward error callback from parser. */ static void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message); /* Configure the parser to support large input. */ #define YYMAXDEPTH 100000 #define YYINITDEPTH 10000 /* 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 */ #endif #if defined(__GNUC__) && __GNUC__ >= 8 # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wfree-nonheap-object" #endif #if defined(__clang__) && defined(__has_warning) # if __has_warning("-Wunused-but-set-variable") # pragma clang diagnostic ignored "-Wunused-but-set-variable" # endif #endif %} /* Generate a reentrant parser object. */ %define api.pure /* Configure the parser to use a lexer object. */ %lex-param {yyscan_t yyscanner} %parse-param {yyscan_t yyscanner} %define parse.error verbose /* %union { char* string; } */ /*-------------------------------------------------------------------------*/ /* Tokens */ %token cal_ENVCURLY %token cal_NCURLY %token cal_DCURLY %token cal_DOLLAR "$" %token cal_LCURLY "{" %token cal_RCURLY "}" %token cal_NAME %token cal_BSLASH "\\" %token cal_SYMBOL %token cal_AT "@" %token cal_ERROR %token cal_ATNAME /*-------------------------------------------------------------------------*/ /* grammar */ %% Start: GoalWithOptionalBackSlash { $$ = 0; yyGetParser->SetResult($1); } GoalWithOptionalBackSlash: Goal { $$ = $1; } | Goal cal_BSLASH { $$ = yyGetParser->CombineUnions($1, $2); } Goal: { $$ = 0; } | String Goal { $$ = yyGetParser->CombineUnions($1, $2); } String: OuterText { $$ = $1; } | Variable { $$ = $1; } OuterText: cal_NAME { $$ = $1; } | cal_AT { $$ = $1; } | cal_DOLLAR { $$ = $1; } | cal_LCURLY { $$ = $1; } | cal_RCURLY { $$ = $1; } | cal_SYMBOL { $$ = $1; } Variable: cal_ENVCURLY EnvVarName cal_RCURLY { $$ = yyGetParser->ExpandSpecialVariable($1, $2); } | cal_NCURLY MultipleIds cal_RCURLY { $$ = yyGetParser->ExpandSpecialVariable($1, $2); } | cal_DCURLY MultipleIds cal_RCURLY { $$ = yyGetParser->ExpandVariable($2); } | cal_ATNAME { $$ = yyGetParser->ExpandVariableForAt($1); } EnvVarName: MultipleIds { $$ = $1; } | cal_SYMBOL EnvVarName { $$ = $1; } MultipleIds: { $$ = 0; } | ID MultipleIds { $$ = yyGetParser->CombineUnions($1, $2); } ID: cal_NAME { $$ = $1; } | Variable { $$ = $1; } ; %% /* End of grammar */ /*--------------------------------------------------------------------------*/ void cmCommandArgument_yyerror(yyscan_t yyscanner, const char* message) { yyGetParser->Error(message); }