Removed from tracking a bunch files: ".o" object files, executables (faust and fausti...
[Faustine.git] / interpretor / faust-0.9.47mr3 / compiler / parser / faustlexer.l
1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4 -*- */
2
3 /* Scanner for the Faust language */
4
5 %{
6 #include "tree.hh"
7 #include "faustparser.hpp"
8 #define YY_NO_UNISTD_H 1
9 extern int isatty (int );
10 %}
11
12 DIGIT [0-9]
13 ID [a-zA-Z][_a-zA-Z0-9]*
14 LETTER [a-zA-Z]
15 NUMBER ({DIGIT}+"."{DIGIT}*|"."{DIGIT}+|{DIGIT}+)
16 WSPACE [ \t\n]
17 TMACRO \\{ID}(\[(\ *({ID}|{NUMBER}),?\ *)\])?(\{(\ *({ID}|{NUMBER}),?\ *)*\})*
18
19 %option yylineno
20 %x comment
21 %x doc
22 %x lst
23
24
25 %%
26
27
28 "/*" BEGIN(comment);
29 <comment>[^*\x0a\x0d]* /* eat anything that's not a '*' */
30 <comment>"*"+[^*/\x0a\x0d]* /* eat up '*'s not followed by '/'s */
31 <comment>\x0a\x0d /* no need to increment yylineno here */
32 <comment>\x0a /* no need to increment yylineno here */
33 <comment>\x0d /* no need to increment yylineno here */
34 <comment>"*"+"/" BEGIN(INITIAL);
35
36 "<mdoc>" { BEGIN(doc); return BDOC; }
37 <doc>. return DOCCHAR; /* char by char, may be slow ?? */
38 <doc>\n return DOCCHAR; /* keep newline chars */
39 <doc>"<notice/>" return NOTICE; /* autoclosing tag */
40 <doc>"<notice />" return NOTICE; /* autoclosing tag */
41 <doc>"<listing" { BEGIN(lst); return BLST; } /* autoclosing tag */
42 <doc>"<equation>" { BEGIN(INITIAL); return BEQN; }
43 "</equation>" { BEGIN(doc); return EEQN; }
44 <doc>"<diagram>" { BEGIN(INITIAL); return BDGM; }
45 "</diagram>" { BEGIN(doc); return EDGM; }
46 <doc>"<metadata>" { BEGIN(INITIAL); return BMETADATA; }
47 "</metadata>" { BEGIN(doc); return EMETADATA; }
48 <doc>"</mdoc>" { BEGIN(INITIAL); return EDOC; }
49
50 <lst>"true" return LSTTRUE;
51 <lst>"false" return LSTFALSE;
52 <lst>"dependencies" return LSTDEPENDENCIES;
53 <lst>"mdoctags" return LSTMDOCTAGS;
54 <lst>"distributed" return LSTDISTRIBUTED;
55 <lst>"=" return LSTEQ;
56 <lst>"\"" return LSTQ;
57 <lst>"/>" { BEGIN(doc); return ELST; }
58
59
60 {DIGIT}+ return INT;
61
62
63 {DIGIT}+"."{DIGIT}* return FLOAT;
64 {DIGIT}+"."{DIGIT}*e[-+]?{DIGIT}+ return FLOAT;
65 {DIGIT}+e[-+]?{DIGIT}+ return FLOAT;
66 "."{DIGIT}+ return FLOAT;
67 "."{DIGIT}+e[-+]?{DIGIT}+ return FLOAT;
68
69
70 ":" return SEQ;
71 "," return PAR;
72 "<:" return SPLIT;
73 "+>" return MIX;
74 ":>" return MIX;
75 "~" return REC;
76
77 "+" return ADD;
78 "-" return SUB;
79 "*" return MUL;
80 "/" return DIV;
81 "%" return MOD;
82 "@" return FDELAY;
83 "'" return DELAY1;
84
85 "&" return AND;
86 "|" return OR;
87 "xor" return XOR;
88
89 "<<" return LSH;
90 ">>" return RSH;
91
92 "<" return LT;
93 "<=" return LE;
94 ">" return GT;
95 ">=" return GE;
96 "==" return EQ;
97 "!=" return NE;
98
99 "_" return WIRE;
100 "!" return CUT;
101
102 ";" return ENDDEF;
103 "=" return DEF;
104 "(" return LPAR;
105 ")" return RPAR;
106 "{" return LBRAQ;
107 "}" return RBRAQ;
108 "[" return LCROC;
109 "]" return RCROC;
110
111 "\\" return LAMBDA;
112 "." return DOT;
113 "with" return WITH;
114
115 "mem" return MEM;
116 "prefix" return PREFIX;
117
118 "int" return INTCAST;
119 "float" return FLOATCAST;
120
121 "rdtable" return RDTBL;
122 "rwtable" return RWTBL;
123
124 "select2" return SELECT2;
125 "select3" return SELECT3;
126
127 "ffunction" return FFUNCTION;
128 "fconstant" return FCONSTANT;
129 "fvariable" return FVARIABLE;
130
131 "button" return BUTTON;
132 "checkbox" return CHECKBOX;
133 "vslider" return VSLIDER;
134 "hslider" return HSLIDER;
135 "nentry" return NENTRY;
136 "vgroup" return VGROUP;
137 "hgroup" return HGROUP;
138 "tgroup" return TGROUP;
139 "vbargraph" return VBARGRAPH;
140 "hbargraph" return HBARGRAPH;
141 "attach" return ATTACH;
142
143 "acos" return ACOS;
144 "asin" return ASIN;
145 "atan" return ATAN;
146 "atan2" return ATAN2;
147
148 "cos" return COS;
149 "sin" return SIN;
150 "tan" return TAN;
151
152 "exp" return EXP;
153 "log" return LOG;
154 "log10" return LOG10;
155 "^" return POWOP;
156 "pow" return POWFUN;
157 "sqrt" return SQRT;
158
159 "abs" return ABS;
160 "min" return MIN;
161 "max" return MAX;
162
163 "fmod" return FMOD;
164 "remainder" return REMAINDER;
165
166 "floor" return FLOOR;
167 "ceil" return CEIL;
168 "rint" return RINT;
169
170 "seq" return ISEQ;
171 "par" return IPAR;
172 "sum" return ISUM;
173 "prod" return IPROD;
174
175 "import" return IMPORT;
176 "component" return COMPONENT;
177 "library" return LIBRARY;
178 "environment" return ENVIRONMENT;
179
180 "declare" return DECLARE;
181
182 "serialize" return SERIALIZE;
183 "vectorize" return VECTORIZE;
184 "#" return HASH;
185 "rate" return RATE;
186
187 "up" return UPSAMPLE;
188 "down" return DOWNSAMPLE;
189
190 "case" return CASE;
191 "=>" return ARROW;
192
193 _{ID} return IDENT;
194 {ID} return IDENT;
195
196 "\""[^\"]*"\"" return STRING;
197
198 "<"{LETTER}*"."{LETTER}">" return FSTRING;
199 "<"{LETTER}*">" return FSTRING;
200
201
202 "//"[^\x0a\x0d]* /* eat up one-line comments */
203
204 [ \t\x0a\x0d]+ /* eat up whitespace */
205
206 <<EOF>> yyterminate();
207
208 . printf("extra text is : %s\n", yytext); return EXTRA;
209
210
211 %%
212 int yywrap() { return 1; }
213