2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmExprParser.y,v $
7 Date: $Date: 2006-08-01 15:38:41 $
8 Version: $Revision: 1.3 $
10 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
11 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
20 This file must be translated to C and modified to build everywhere.
24 bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
26 Modify cmExprParser.cxx:
28 - add __HP_aCC to the #if test for yyerrorlab warning suppression
32 /* Configure the parser to use a lexer object. */
33 #define YYPARSE_PARAM yyscanner
34 #define YYLEX_PARAM yyscanner
35 #define YYERROR_VERBOSE 1
36 #define cmExpr_yyerror(x) \
37 cmExprError
(yyscanner
, x
)
38 #define yyGetParser (cmExpr_yyget_extra(yyscanner))
40 /*-------------------------------------------------------------------------*/
41 #include "cmExprParserHelper.h" /* Interface to parser object. */
42 #include "cmExprLexer.h" /* Interface to lexer object. */
43 #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
47 /* Forward declare the lexer entry point. */
50 /* Internal utility functions. */
51 static void cmExprError
(yyscan_t yyscanner
, const char* message
);
54 //#define YYMAXDEPTH 100000
55 //#define YYINITDEPTH 10000
58 /* Disable some warnings in the generated code. */
60 # pragma warn -8004 /* Variable assigned a value that is not used. */
61 # pragma warn -8008 /* condition always returns true */
62 # pragma warn -8060 /* possibly incorrect assignment */
63 # pragma warn -8066 /* unreachable code */
66 # pragma warning (disable: 4102) /* Unused goto label. */
67 # pragma warning (disable: 4065) /* Switch statement contains default but no case. */
71 /* Generate a reentrant parser object. */
74 /*-------------------------------------------------------------------------*/
84 %token exp_CLOSEPARENT
91 /*-------------------------------------------------------------------------*/
99 yyGetParser
->SetResult
($
<Number
>1);
104 {$
<Number
>$
= $
<Number
>1;}
107 {$
<Number
>$
= $
<Number
>1 | $
<Number
>3;}
111 {$
<Number
>$
= $
<Number
>1;}
113 bitwiseor exp_XOR bitwisexor
114 {$
<Number
>$
= $
<Number
>1 ^ $
<Number
>3;}
118 {$
<Number
>$
= $
<Number
>1;}
120 bitwisexor exp_AND bitwiseand
121 {$
<Number
>$
= $
<Number
>1 & $
<Number
>3;}
125 {$
<Number
>$
= $
<Number
>1;}
127 bitwiseand exp_SHIFTLEFT shift
128 {$
<Number
>$
= $
<Number
>1 << $
<Number
>3;}
130 bitwiseand exp_SHIFTRIGHT shift
131 {$
<Number
>$
= $
<Number
>1 >> $
<Number
>3;}
136 {$
<Number
>$
= $
<Number
>1;}
139 {$
<Number
>$
= $
<Number
>1 + $
<Number
>3;}
142 {$
<Number
>$
= $
<Number
>1 - $
<Number
>3;}
146 {$
<Number
>$
= $
<Number
>1;}
148 term exp_TIMES factor
149 {$
<Number
>$
= $
<Number
>1 * $
<Number
>3;}
151 term exp_DIVIDE factor
152 {$
<Number
>$
= $
<Number
>1 / $
<Number
>3;}
155 {$
<Number
>$
= $
<Number
>1 % $
<Number
>3;}
159 {$
<Number
>$
= $
<Number
>1;}
161 exp_OPENPARENT exp exp_CLOSEPARENT
162 {$
<Number
>$
= $
<Number
>2;}
169 /*--------------------------------------------------------------------------*/
170 void cmExprError
(yyscan_t yyscanner
, const char* message
)
172 yyGetParser
->Error
(message
);