📄 remez.l
字号:
%{
/*
* YACC grammar for the Remez Exchange FIR Filter Design Program
* Copyright (C) 1999 Jim A. Ledin (jim@ledin.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "remez.tab.h"
#include <string.h>
#include <vector>
int LineNumber, ErrorCount;
void c_comment();
void cpp_comment();
void yyerror(char* s);
#define YY_NEVER_INTERACTIVE 1
%}
digit [0-9]
integer {digit}+
real {integer}"."?|({integer}?"."{integer})
c_comment "/*"
cpp_comment "//"
%%
[\n\f\v] { LineNumber++; }
[ \t\r] ;
{c_comment} { c_comment(); }
{cpp_comment} { cpp_comment(); }
{real} { yylval.real_val = atof(yytext);
return REAL;
}
bands { return BANDS; }
weights { return WEIGHTS; }
amplitudes { return AMPLITUDES; }
type { return TYPE; }
order { return ORDER; }
bandpass { return BANDPASS_FILTER; }
hilbert { return HILBERT_FILTER; }
differentiator { return DIFFERENTIATOR_FILTER; }
. { return *yytext; }
%%
void yyerror(char* s) {
extern int yychar;
ErrorCount++;
char buf[500];
sprintf(buf,"\nERROR: %s on line %d\n", s, LineNumber);
if (strlen(yytext) > 0)
{
char buf2[200];
sprintf(buf2, "Offending text: %s\n", yytext);
strcat(buf, buf2);
}
fprintf(stderr, buf);
}
int yywrap(void)
{
return 1;
}
void c_comment() {
int c = '\0', prev_c;
do {
prev_c = c;
c = yyinput();
if (c == '\n')
LineNumber++;
} while ((prev_c != '*' || c != '/') && c != EOF);
if (c == EOF)
yyerror("unterminated comment");
return;
}
void cpp_comment() {
int c;
do {
c = yyinput();
} while (c != '\n' && c != EOF);
LineNumber++;
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -