2
/***************************************************************************
3
* Copyright (C) 2005 by Alexander Dymo *
6
* Copyright (c) 2005 by Matt Rogers *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU Library General Public License as *
11
* published by the Free Software Foundation; either version 2 of the *
12
* License, or (at your option) any later version. *
14
* This program is distributed in the hope that it will be useful, *
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17
* GNU General Public License for more details. *
19
* You should have received a copy of the GNU Library General Public *
20
* License along with this program; if not, write to the *
21
* Free Software Foundation, Inc., *
22
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23
***************************************************************************/
25
#include <autotools_yacc.h>
32
There are 3 types of identifiers recognized by this lexer:
33
-id_simple: examples of such identifiers are qmake variables and scoped variables
34
at the left of the operator in assignments (like "SOURCES" in "SOURCES+=foo.cpp goo.cpp");
35
-id_list: those are "value list identifiers" at the right side in assignments
36
(like "foo.cpp goo.cpp" in "SOURCES+=foo.cpp goo.cpp");
37
-id_args: function arguments recognized as one identifier
38
(example: ""${QMAKE_FILE} is intended only for Windows!""
39
in "!win32-*:!wince-*:error("${QMAKE_FILE} is intended only for Windows!")" statements).
42
To recognize those identifiers two additional start conditions are used: list and funcargs.
44
@note "Not" operator (!) is recognized as a part of an identifier. Linefeeds passed to
45
the parser as NEWLINE tokens to preserve file structure but whitespaces are stripped
46
so no indentation is preserved by this lexer (and parser).
48
To debug this lexer, put the line below into the next flex file section.
62
id_simple ({digit}|{letter}|\!|-|_|\*|\$|@)({letter}|{digit}|\||\!|-|_|\*|\$|\(|\.|\+|\-|\)|\/)*
67
comment_cont {ws}*#.*\n
70
keywords (if|else|endif|include)
76
<list,INITIAL>{cont} { BEGIN(list); return CONT; }
78
yylval.value = yytext;
79
if ( yylval.value == "if" )
82
if ( yylval.value == "else" )
85
if ( yylval.value == "endif" )
92
{id_simple} { yylval.value = yytext; return (ID_SIMPLE); }
95
yylval.value = yytext;
100
yylval.value = yytext;
101
yylval.value = yylval.value.mid(0, yylval.value.findRev("\\"));
107
<list>{comment_cont} {
108
yylval.value = yytext;
110
return (LIST_COMMENT);
113
<list>{id_list_single} {
114
yylval.value = yytext;
116
return (ID_LIST_SINGLE);
119
<funcargs>{id_args} {
120
yylval.value = yytext;
121
yylval.value = yylval.value.mid(0, yylval.value.length()-1);
127
"=" { BEGIN(list); yylval.value = yytext; return EQ; }
128
"+=" { BEGIN(list); yylval.value = yytext; return PLUSEQ; }
129
"{" { return LCURLY; }
130
"}" { return RCURLY; }
131
":" { BEGIN(list); yylval.value = yytext; return COLON; }
132
<list,INITIAL>"\n" { BEGIN(INITIAL); return NEWLINE; }
133
{comment} { yylval.value = yytext; return (COMMENT); }