1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4 -*- */
/* Scanner for the Faust language */
%{
#include "tree.hh"
#include "faustparser.hpp"
#if defined(WIN32)
#if !defined(__MINGW32__) && !defined(__MSYS__)
// We don't want to include compatibility.hh here, since it pulls in whole lot
// of unneeded stuff which breaks other things, so here's some stuff to make
// MSVC happy.
#include <io.h>
#define isatty _isatty
#define fileno _fileno
#define YY_NO_UNISTD_H
#endif
#else
#include "compatibility.hh"
#include "errormsg.hh"
#define YY_FATAL_ERROR lexerror
#endif
#define register // suppress the deprecated 'register' warning
%}
DIGIT [0-9]
ID _*[a-zA-Z][_a-zA-Z0-9]*
LETTER [a-zA-Z]
NUMBER ({DIGIT}+"."{DIGIT}*|"."{DIGIT}+|{DIGIT}+)
WSPACE [ \t\n]
TMACRO \\{ID}(\[(\ *({ID}|{NUMBER}),?\ *)\])?(\{(\ *({ID}|{NUMBER}),?\ *)*\})*
NSID {ID}("::"{ID})*
%option yylineno
%option nounput
%x comment
%x doc
%x lst
%%
"/*" BEGIN(comment);
<comment>[^*\x0a\x0d]* /* eat anything that's not a '*' */
<comment>"*"+[^*/\x0a\x0d]* /* eat up '*'s not followed by '/'s */
<comment>\x0a\x0d /* no need to increment yylineno here */
<comment>\x0a /* no need to increment yylineno here */
<comment>\x0d /* no need to increment yylineno here */
<comment>"*"+"/" BEGIN(INITIAL);
"<mdoc>" { BEGIN(doc); return BDOC; }
<doc>. return DOCCHAR; /* char by char, may be slow ?? */
<doc>\n return DOCCHAR; /* keep newline chars */
<doc>"<notice/>" return NOTICE; /* autoclosing tag */
<doc>"<notice />" return NOTICE; /* autoclosing tag */
<doc>"<listing" { BEGIN(lst); return BLST; } /* autoclosing tag */
<doc>"<equation>" { BEGIN(INITIAL); return BEQN; }
"</equation>" { BEGIN(doc); return EEQN; }
<doc>"<diagram>" { BEGIN(INITIAL); return BDGM; }
"</diagram>" { BEGIN(doc); return EDGM; }
<doc>"<metadata>" { BEGIN(INITIAL); return BMETADATA; }
"</metadata>" { BEGIN(doc); return EMETADATA; }
<doc>"</mdoc>" { BEGIN(INITIAL); return EDOC; }
<lst>"true" return LSTTRUE;
<lst>"false" return LSTFALSE;
<lst>"dependencies" return LSTDEPENDENCIES;
<lst>"mdoctags" return LSTMDOCTAGS;
<lst>"distributed" return LSTDISTRIBUTED;
<lst>"=" return LSTEQ;
<lst>"\"" return LSTQ;
<lst>"/>" { BEGIN(doc); return ELST; }
{DIGIT}+ return INT;
{DIGIT}+"f" return FLOAT;
{DIGIT}+"."{DIGIT}* return FLOAT;
{DIGIT}+"."{DIGIT}*"f" return FLOAT;
{DIGIT}+"."{DIGIT}*e[-+]?{DIGIT}+ return FLOAT;
{DIGIT}+"."{DIGIT}*e[-+]?{DIGIT}+"f" return FLOAT;
{DIGIT}+e[-+]?{DIGIT}+ return FLOAT;
{DIGIT}+e[-+]?{DIGIT}+"f" return FLOAT;
"."{DIGIT}+ return FLOAT;
"."{DIGIT}+"f" return FLOAT;
"."{DIGIT}+e[-+]?{DIGIT}+ return FLOAT;
"."{DIGIT}+e[-+]?{DIGIT}+"f" return FLOAT;
":" return SEQ;
"," return PAR;
"<:" return SPLIT;
"+>" return MIX;
":>" return MIX;
"~" return REC;
"+" return ADD;
"-" return SUB;
"*" return MUL;
"/" return DIV;
"%" return MOD;
"@" return FDELAY;
"'" return DELAY1;
"&" return AND;
"|" return OR;
"xor" return XOR;
"<<" return LSH;
">>" return RSH;
"<" return LT;
"<=" return LE;
">" return GT;
">=" return GE;
"==" return EQ;
"!=" return NE;
"_" return WIRE;
"!" return CUT;
";" return ENDDEF;
"=" return DEF;
"(" return LPAR;
")" return RPAR;
"{" return LBRAQ;
"}" return RBRAQ;
"[" return LCROC;
"]" return RCROC;
"\\" return LAMBDA;
"." return DOT;
"with" return WITH;
"letrec" return LETREC;
"where" return WHERE;
"mem" return MEM;
"prefix" return PREFIX;
"int" return INTCAST;
"float" return FLOATCAST;
"any" return NOTYPECAST;
"rdtable" return RDTBL;
"rwtable" return RWTBL;
"select2" return SELECT2;
"select3" return SELECT3;
"ffunction" return FFUNCTION;
"fconstant" return FCONSTANT;
"fvariable" return FVARIABLE;
"button" return BUTTON;
"checkbox" return CHECKBOX;
"vslider" return VSLIDER;
"hslider" return HSLIDER;
"nentry" return NENTRY;
"vgroup" return VGROUP;
"hgroup" return HGROUP;
"tgroup" return TGROUP;
"vbargraph" return VBARGRAPH;
"hbargraph" return HBARGRAPH;
"soundfile" return SOUNDFILE;
"attach" return ATTACH;
"minput" return MODULATE;
"acos" return ACOS;
"asin" return ASIN;
"atan" return ATAN;
"atan2" return ATAN2;
"cos" return COS;
"sin" return SIN;
"tan" return TAN;
"exp" return EXP;
"log" return LOG;
"log10" return LOG10;
"^" return POWOP;
"pow" return POWFUN;
"sqrt" return SQRT;
"abs" return ABS;
"min" return MIN;
"max" return MAX;
"fmod" return FMOD;
"remainder" return REMAINDER;
"floor" return FLOOR;
"ceil" return CEIL;
"rint" return RINT;
"round" return ROUND;
"seq" return ISEQ;
"par" return IPAR;
"sum" return ISUM;
"prod" return IPROD;
"inputs" return INPUTS;
"outputs" return OUTPUTS;
"import" return IMPORT;
"component" return COMPONENT;
"library" return LIBRARY;
"environment" return ENVIRONMENT;
"waveform" return WAVEFORM;
"route" return ROUTE;
"enable" return ENABLE;
"control" return CONTROL;
"declare" return DECLARE;
"case" return CASE;
"=>" return ARROW;
"->" return LAPPLY;
"assertbounds" return ASSERTBOUNDS;
"lowest" return LOWEST;
"highest" return HIGHEST;
"singleprecision" return FLOATMODE;
"doubleprecision" return DOUBLEMODE;
"quadprecision" return QUADMODE;
"fixedpointprecision" return FIXEDPOINTMODE;
"::"{NSID} return IDENT;
{NSID} return IDENT;
"\""[^\"]*"\"" return STRING;
"<"{LETTER}*"."{LETTER}">" return FSTRING;
"<"{LETTER}*">" return FSTRING;
"//"[^\x0a\x0d]* /* eat up one-line comments */
[ \t\x0a\x0d]+ /* eat up whitespace */
<<EOF>> yyterminate();
. printf("extra text is : %s\n", yytext); return EXTRA;
%%
int yywrap() { return 1; }
|