1 /******************************************************************************
3 * $Id: constexp.l,v 1.11 2001/03/19 19:27:40 root Exp $
6 * Copyright (C) 1997-2012 by Dimitri van Heesch.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation under the terms of the GNU General Public License is hereby
10 * granted. No representations are made about the suitability of this software
11 * for any purpose. It is provided "as is" without express or implied warranty.
12 * See the GNU General Public License for more details.
14 * Documents produced by Doxygen are derivative works derived from the
15 * input used in their production; they are not affected by this license.
23 #include "ce_parse.h" // generated header file
25 #define YY_NEVER_INTERACTIVE 1
29 CPPValue g_resultValue;
31 QCString g_constExpFileName;
33 static const char *g_inputString;
34 static int g_inputPosition;
37 #define YY_INPUT(buf,result,max_size) result=yyread(buf,max_size);
39 static int yyread(char *buf,int max_size)
42 while( c < max_size && g_inputString[g_inputPosition] )
44 *buf = g_inputString[g_inputPosition++] ;
52 CONSTSUFFIX ([uU][lL]?[lL]?)|([lL][lL]?[uU]?)
58 "?" { return TOK_QUESTIONMARK; }
59 ":" { return TOK_COLON; }
60 "||" { return TOK_OR; }
61 "&&" { return TOK_AND; }
62 "|" { return TOK_BITWISEOR; }
63 "^" { return TOK_BITWISEXOR; }
64 "&" { return TOK_AMPERSAND; }
65 "!=" { return TOK_NOTEQUAL; }
66 "==" { return TOK_EQUAL; }
67 "<" { return TOK_LESSTHAN; }
68 ">" { return TOK_GREATERTHAN; }
69 "<=" { return TOK_LESSTHANOREQUALTO; }
70 ">=" { return TOK_GREATERTHANOREQUALTO; }
71 "<<" { return TOK_SHIFTLEFT; }
72 ">>" { return TOK_SHIFTRIGHT; }
73 "+" { return TOK_PLUS; }
74 "-" { return TOK_MINUS; }
75 "*" { return TOK_STAR; }
76 "/" { return TOK_DIVIDE; }
77 "%" { return TOK_MOD; }
78 "~" { return TOK_TILDE; }
79 "!" { return TOK_NOT; }
80 "(" { return TOK_LPAREN; }
81 ")" { return TOK_RPAREN; }
82 "'"(([^\'\n\r\\]+)|(\\(([ntvbrfa\\?'\"])|([0-9]+)|([xX][0-9a-fA-F]+))))"'" {
86 0[0-7]*{CONSTSUFFIX}? { g_strToken=yytext;
89 [1-9][0-9]*{CONSTSUFFIX}? { g_strToken=yytext;
90 return TOK_DECIMALINT;
92 (0x|0X)[0-9a-fA-F]+{CONSTSUFFIX}? { g_strToken=yytext+2;
93 return TOK_HEXADECIMALINT;
95 (([0-9]+\.[0-9]*)|([0-9]*\.[0-9]+))([eE]([\-\+])?[0-9]+)?([fFlL])? {
96 g_strToken=yytext; return TOK_FLOAT;
98 ([0-9]+[eE])([\-\+])?[0-9]+([fFlL])? {
99 g_strToken=yytext; return TOK_FLOAT;
106 bool parseCppExpression(const char *fileName,int lineNr,const QCString &s)
108 //printf("Expression: `%s'\n",s.data());
109 g_constExpFileName = fileName;
110 g_constExpLineNr = lineNr;
113 cppExpYYrestart( cppExpYYin );
115 //printf("Result: %ld\n",(long)g_resultValue);
116 return (long)g_resultValue!=0;
120 int cppExpYYwrap() { return 1; }