Add wrapper for GstXOverlay and fix codegen to be able to use more gstreamer includes...
[qtgstreamer:qtgstreamer.git] / codegen / analyzer.l
1 /*
2     Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
3
4     This library is free software; you can redistribute it and/or modify
5     it under the terms of the GNU Lesser General Public License as published
6     by the Free Software Foundation; either version 2.1 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU Lesser General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 %{
18 #include "yystype.h"
19 #include "generator.h"
20
21 #define YY_DECL int yylex(CodeGen *codegen)
22 void yyerror(CodeGen *codegen, const char *msg);
23
24 %}
25 %option noyywrap
26 %option yylineno
27 %option stack
28
29 id      [a-zA-Z][a-zA-Z_0-9]*
30
31 %x REGISTER_TYPE
32 %x ENUM
33 %x ENUM_EAT_ASSIGNMENT
34 %x INSTRUCTION
35 %x LINE_COMMENT
36 %x C_STYLE_COMMENT
37 %x NAMESPACE
38 %x CLASS
39 %x EAT_TEMPLATE
40 %x MACRO
41
42 %%
43
44 <REGISTER_TYPE,ENUM,INSTRUCTION>{id} { yylval.Id = new QByteArray(yytext); return IDENTIFIER;  }
45
46 QGLIB_REGISTER_TYPE\(    { yy_push_state(REGISTER_TYPE); return REGISTER_TYPE_BEGIN; }
47 <REGISTER_TYPE>{
48     ::                   { return SCOPE_RESOLUTION_OPERATOR; }
49     \)                   { yy_pop_state(); return REGISTER_TYPE_END; }
50     [[:space:]]*
51     .                    { yyerror(codegen, "Syntax error in QGLIB_REGISTER_TYPE"); }
52 }
53
54 enum                     { yy_push_state(ENUM); return ENUM_KEYWORD; }
55 <ENUM>{
56     \{                   { return LEFT_BRACE; }
57     \}                   { return RIGHT_BRACE; }
58     ,                    { return COMMA; }
59     =                    { yy_push_state(ENUM_EAT_ASSIGNMENT); }
60     ;                    { yy_pop_state(); return SEMICOLON; }
61     [[:space:]]*
62     .                    { yyerror(codegen, "Syntax error in enum definition"); }
63 }
64
65 <ENUM_EAT_ASSIGNMENT>{
66     ,                    { unput(','); yy_pop_state(); }
67     \}                   { unput('}'); yy_pop_state(); }
68     \n
69     .
70 }
71
72 <*>\/\/                  { yy_push_state(LINE_COMMENT); }
73 <LINE_COMMENT>{
74     \n                   { yy_pop_state(); }
75     codegen:             { yy_push_state(INSTRUCTION); return INSTRUCTIONS_BEGIN; }
76     .
77 }
78
79 <INSTRUCTION>{
80     \n                   { unput('\n'); yy_pop_state(); return INSTRUCTIONS_END; }
81     =                    { return INSTRUCTIONS_ASSIGN_OPERATOR; }
82     ,                    { return INSTRUCTIONS_SEPARATOR; }
83     [[:space:]]
84     .                    { yyerror(codegen, "Syntax error in instruction comment"); }
85 }
86
87 <*>\/\*                  { yy_push_state(C_STYLE_COMMENT); }
88 <C_STYLE_COMMENT>{
89     \*\/                 { yy_pop_state(); }
90     \n
91     .
92 }
93
94 namespace                { yy_push_state(NAMESPACE); }
95 <NAMESPACE>{
96     {id}                 { codegen->setCurrentNameSpace(yytext); yy_pop_state(); }
97     [[:space:]]*
98     .                    { yyerror(codegen, "Expected identifier after namespace keyword"); }
99 }
100
101 class                    { yy_push_state(CLASS); }
102 <CLASS>{
103     {id}                 { codegen->setCurrentClass(yytext); yy_pop_state(); }
104     [[:space:]]*
105     .                    { yyerror(codegen, "Expected identifier after class keyword"); }
106 }
107
108 template[[:space:]]*\<   { yy_push_state(EAT_TEMPLATE); }
109 <EAT_TEMPLATE>{
110     \<                   { yy_push_state(EAT_TEMPLATE); };
111     \>                   { yy_pop_state(); }
112     \n
113     .
114 }
115
116  /* Eats only one-line defines. Used to eat the #define QGLIB_REGISTER_TYPE(T),
117     which would be a syntax error for codegen otherwise. */
118 #define                  { yy_push_state(MACRO); }
119 <MACRO>{
120     \n                   { yy_pop_state(); }
121     .
122 }
123
124 <*><<EOF>>               { return EOF; }
125 \n
126 .
127
128 %%
129