BUG: Fix find_* search order with path suffixes
[cmake.git] / Source / cmExprParser.y
blob864c02646f384168ebafb1be6146f543a9944849
1 %{
2 /*=========================================================================
4 Program: CMake - Cross-Platform Makefile Generator
5 Module: $RCSfile: cmExprParser.y,v $
6 Language: C++
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.
22 Run bison like this:
24 bison --yacc --name-prefix=cmExpr_yy --defines=cmExprParserTokens.h -ocmExprParser.cxx cmExprParser.y
26 Modify cmExprParser.cxx:
27 - remove TABs
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. */
45 #include <math.h>
47 /* Forward declare the lexer entry point. */
48 YY_DECL;
50 /* Internal utility functions. */
51 static void cmExprError(yyscan_t yyscanner, const char* message);
53 #define YYDEBUG 1
54 //#define YYMAXDEPTH 100000
55 //#define YYINITDEPTH 10000
58 /* Disable some warnings in the generated code. */
59 #ifdef __BORLANDC__
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 */
64 #endif
65 #ifdef _MSC_VER
66 # pragma warning (disable: 4102) /* Unused goto label. */
67 # pragma warning (disable: 4065) /* Switch statement contains default but no case. */
68 #endif
71 /* Generate a reentrant parser object. */
72 %pure_parser
74 /*-------------------------------------------------------------------------*/
75 /* Tokens */
76 %token exp_PLUS
77 %token exp_MINUS
78 %token exp_TIMES
79 %token exp_DIVIDE
80 %token exp_MOD
81 %token exp_SHIFTLEFT
82 %token exp_SHIFTRIGHT
83 %token exp_OPENPARENT
84 %token exp_CLOSEPARENT
85 %token exp_OR;
86 %token exp_AND;
87 %token exp_XOR;
88 %token exp_NOT;
89 %token exp_NUMBER;
91 /*-------------------------------------------------------------------------*/
92 /* grammar */
96 Start:
97 exp
99 yyGetParser->SetResult($<Number>1);
102 exp:
103 bitwiseor
104 {$<Number>$ = $<Number>1;}
106 exp exp_OR bitwiseor
107 {$<Number>$ = $<Number>1 | $<Number>3;}
109 bitwiseor:
110 bitwisexor
111 {$<Number>$ = $<Number>1;}
113 bitwiseor exp_XOR bitwisexor
114 {$<Number>$ = $<Number>1 ^ $<Number>3;}
116 bitwisexor:
117 bitwiseand
118 {$<Number>$ = $<Number>1;}
120 bitwisexor exp_AND bitwiseand
121 {$<Number>$ = $<Number>1 & $<Number>3;}
123 bitwiseand:
124 shift
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;}
134 shift:
135 term
136 {$<Number>$ = $<Number>1;}
138 shift exp_PLUS term
139 {$<Number>$ = $<Number>1 + $<Number>3;}
141 shift exp_MINUS term
142 {$<Number>$ = $<Number>1 - $<Number>3;}
144 term:
145 factor
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;}
154 term exp_MOD factor
155 {$<Number>$ = $<Number>1 % $<Number>3;}
157 factor:
158 exp_NUMBER
159 {$<Number>$ = $<Number>1;}
161 exp_OPENPARENT exp exp_CLOSEPARENT
162 {$<Number>$ = $<Number>2;}
167 /* End of grammar */
169 /*--------------------------------------------------------------------------*/
170 void cmExprError(yyscan_t yyscanner, const char* message)
172 yyGetParser->Error(message);