~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to buildtools/lib/parsers/autotools/autotools.ll

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
/***************************************************************************
 
3
 *   Copyright (C) 2005 by Alexander Dymo                                  *
 
4
 *   adymo@kdevelop.org                                                    *
 
5
 *                                                                         *
 
6
 *   Copyright (c) 2005 by Matt Rogers                                     *
 
7
 *   mattr@kde.org                                                         *
 
8
 *                                                                         *
 
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.                       *
 
13
 *                                                                         *
 
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.                          *
 
18
 *                                                                         *
 
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
 ***************************************************************************/
 
24
 
 
25
#include <autotools_yacc.h>
 
26
#include <stdlib.h>
 
27
 
 
28
/**
 
29
@file autotools.ll
 
30
Autotools Lexer
 
31
 
 
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).
 
40
.
 
41
 
 
42
To recognize those identifiers two additional start conditions are used: list and funcargs.
 
43
 
 
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).
 
47
 
 
48
To debug this lexer, put the line below into the next flex file section.
 
49
%option debug
 
50
*/
 
51
%}
 
52
%option noyywrap
 
53
 
 
54
%x list
 
55
%x funcargs
 
56
%x conditional
 
57
 
 
58
delim             [ \t]
 
59
ws                {delim}+
 
60
letter            [A-Za-z]
 
61
digit             [0-9]
 
62
id_simple         ({digit}|{letter}|\!|-|_|\*|\$|@)({letter}|{digit}|\||\!|-|_|\*|\$|\(|\.|\+|\-|\)|\/)*
 
63
id_list           [^\n]*\\{ws}*
 
64
id_args           [^\n]*\)
 
65
number            {digit}+
 
66
comment           #.*
 
67
comment_cont      {ws}*#.*\n
 
68
id_list_single    [^\n]*
 
69
cont              \\{ws}*\n
 
70
keywords          (if|else|endif|include)
 
71
rule              [\t]+[^\n]*
 
72
 
 
73
%%
 
74
 
 
75
<list,INITIAL>{ws}     {}
 
76
<list,INITIAL>{cont}   { BEGIN(list); return CONT; }
 
77
{keywords} {
 
78
        yylval.value = yytext;
 
79
        if ( yylval.value == "if" )
 
80
                return IF_KEYWORD;
 
81
        
 
82
        if ( yylval.value == "else" )
 
83
                return ELSE_KEYWORD;
 
84
        
 
85
        if ( yylval.value == "endif" )
 
86
                return ENDIF_KEYWORD;
 
87
        
 
88
        return KEYWORD;
 
89
}
 
90
 
 
91
 
 
92
{id_simple}            { yylval.value = yytext; return (ID_SIMPLE); }
 
93
 
 
94
<INITIAL>{rule} {
 
95
        yylval.value = yytext;
 
96
        return RULE;
 
97
}
 
98
 
 
99
<list>{id_list} {
 
100
        yylval.value = yytext;
 
101
        yylval.value = yylval.value.mid(0, yylval.value.findRev("\\"));
 
102
        unput('\\');
 
103
        BEGIN(INITIAL);
 
104
        return (ID_LIST); 
 
105
    }
 
106
 
 
107
<list>{comment_cont} { 
 
108
        yylval.value = yytext;
 
109
        BEGIN(list);
 
110
        return (LIST_COMMENT); 
 
111
    }
 
112
 
 
113
<list>{id_list_single} {
 
114
        yylval.value = yytext;
 
115
        BEGIN(INITIAL);
 
116
        return (ID_LIST_SINGLE); 
 
117
    }
 
118
 
 
119
<funcargs>{id_args} { 
 
120
        yylval.value = yytext;
 
121
        yylval.value = yylval.value.mid(0, yylval.value.length()-1);
 
122
        unput(')');
 
123
        BEGIN(INITIAL);
 
124
        return (ID_ARGS); 
 
125
    }
 
126
 
 
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); }
 
134
 
 
135
%%
 
136