2 /*============================================================================
3 CMake - Cross Platform Makefile Generator
4 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
6 Distributed under the OSI-approved BSD License (the "License");
7 see accompanying file Copyright.txt for details.
9 This software is distributed WITHOUT ANY WARRANTY; without even the
10 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 See the License for more information.
12 ============================================================================*/
15 This file must be translated to C and modified to build everywhere.
19 bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
21 Modify cmExprParser.cxx:
23 - remove use of the 'register' storage class specifier
24 - add __HP_aCC to the #if test for yyerrorlab warning suppression
28 /* Configure the parser to use a lexer object. */
29 #define YYPARSE_PARAM yyscanner
30 #define YYLEX_PARAM yyscanner
31 #define YYERROR_VERBOSE 1
32 #define cmExpr_yyerror(x) \
33 cmExprError(yyscanner, x)
34 #define yyGetParser (cmExpr_yyget_extra(yyscanner))
36 /*-------------------------------------------------------------------------*/
37 #include "cmExprParserHelper.h" /* Interface to parser object. */
38 #include "cmExprLexer.h" /* Interface to lexer object. */
39 #include "cmExprParserTokens.h" /* Need YYSTYPE for YY_DECL. */
43 /* Forward declare the lexer entry point. */
46 /* Internal utility functions. */
47 static void cmExprError(yyscan_t yyscanner, const char* message);
50 //#define YYMAXDEPTH 100000
51 //#define YYINITDEPTH 10000
54 /* Disable some warnings in the generated code. */
56 # pragma warn -8004 /* Variable assigned a value that is not used. */
57 # pragma warn -8008 /* condition always returns true */
58 # pragma warn -8060 /* possibly incorrect assignment */
59 # pragma warn -8066 /* unreachable code */
62 # pragma warning (disable: 4102) /* Unused goto label. */
63 # pragma warning (disable: 4065) /* Switch statement contains default but no case. */
67 /* Generate a reentrant parser object. */
70 /*-------------------------------------------------------------------------*/
80 %token exp_CLOSEPARENT
87 /*-------------------------------------------------------------------------*/
95 yyGetParser->SetResult($<Number>1);
100 {$<Number>$ = $<Number>1;}
103 {$<Number>$ = $<Number>1 | $<Number>3;}
107 {$<Number>$ = $<Number>1;}
109 bitwiseor exp_XOR bitwisexor
110 {$<Number>$ = $<Number>1 ^ $<Number>3;}
114 {$<Number>$ = $<Number>1;}
116 bitwisexor exp_AND bitwiseand
117 {$<Number>$ = $<Number>1 & $<Number>3;}
121 {$<Number>$ = $<Number>1;}
123 bitwiseand exp_SHIFTLEFT shift
124 {$<Number>$ = $<Number>1 << $<Number>3;}
126 bitwiseand exp_SHIFTRIGHT shift
127 {$<Number>$ = $<Number>1 >> $<Number>3;}
132 {$<Number>$ = $<Number>1;}
135 {$<Number>$ = $<Number>1 + $<Number>3;}
138 {$<Number>$ = $<Number>1 - $<Number>3;}
142 {$<Number>$ = $<Number>1;}
144 term exp_TIMES factor
145 {$<Number>$ = $<Number>1 * $<Number>3;}
147 term exp_DIVIDE factor
148 {$<Number>$ = $<Number>1 / $<Number>3;}
151 {$<Number>$ = $<Number>1 % $<Number>3;}
155 {$<Number>$ = $<Number>1;}
157 exp_OPENPARENT exp exp_CLOSEPARENT
158 {$<Number>$ = $<Number>2;}
165 /*--------------------------------------------------------------------------*/
166 void cmExprError(yyscan_t yyscanner, const char* message)
168 yyGetParser->Error(message);