1 /* -*- Mode: C++; tab-width: 4; c-basic-offset: 4 -*- */
3 /* Scanner for the Faust language */
7 #include "faustparser.hpp"
8 #define YY_NO_UNISTD_H 1
9 extern int isatty (int );
13 ID [a-zA-Z][_a-zA-Z0-9]*
15 NUMBER ({DIGIT}+"."{DIGIT}*|"."{DIGIT}+|{DIGIT}+)
17 TMACRO \\{ID}(\[(\ *({ID}|{NUMBER}),?\ *)\])?(\{(\ *({ID}|{NUMBER}),?\ *)*\})*
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);
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; }
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; }
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;
116 "prefix" return PREFIX;
118 "int" return INTCAST;
119 "float" return FLOATCAST;
121 "rdtable" return RDTBL;
122 "rwtable" return RWTBL;
124 "select2" return SELECT2;
125 "select3" return SELECT3;
127 "ffunction" return FFUNCTION;
128 "fconstant" return FCONSTANT;
129 "fvariable" return FVARIABLE;
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;
146 "atan2" return ATAN2;
154 "log10" return LOG10;
164 "remainder" return REMAINDER;
166 "floor" return FLOOR;
175 "import" return IMPORT;
176 "component" return COMPONENT;
177 "library" return LIBRARY;
178 "environment" return ENVIRONMENT;
180 "declare" return DECLARE;
182 "serialize" return SERIALIZE;
183 "vectorize" return VECTORIZE;
187 "up" return UPSAMPLE;
188 "down" return DOWNSAMPLE;
196 "\""[^\"]*"\"" return STRING;
198 "<"{LETTER}*"."{LETTER}">" return FSTRING;
199 "<"{LETTER}*">" return FSTRING;
202 "//"[^\x0a\x0d]* /* eat up one-line comments */
204 [ \t\x0a\x0d]+ /* eat up whitespace */
206 <<EOF>> yyterminate();
208 . printf("extra text is : %s\n", yytext); return EXTRA;
212 int yywrap() { return 1; }