📄 remez.y
字号:
/*
* 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
*/
%token BANDS WEIGHTS AMPLITUDES TYPE ORDER
%token BANDPASS_FILTER HILBERT_FILTER DIFFERENTIATOR_FILTER
%token REAL
%type <real_val> REAL
%type <real_val> weight_list amplitude_list
%{
#include "remez.h"
#include "types.h"
int yylex(void);
void yyerror(char* s);
%}
%union {
double real_val;
}
%%
stmt_list :
stmt
| stmt_list stmt
;
stmt :
bands_stmt
| weights_stmt
| amplitudes_stmt
| type_stmt
| order_stmt
;
band_edge_pair :
'(' REAL ',' REAL ')'
{ BandEdge.push_back($2); BandEdge.push_back($4); }
;
band_list :
band_edge_pair
| band_list ',' band_edge_pair
;
bands_stmt :
BANDS '=' band_list
{ }
;
weight_list :
REAL
{ Weight.push_back($1); }
| weight_list ',' REAL
{ Weight.push_back($3); }
;
weights_stmt :
WEIGHTS '=' weight_list
{ }
;
amplitude_list :
REAL
{ Amplitude.push_back($1); }
| amplitude_list ',' REAL
{ Amplitude.push_back($3); }
;
amplitudes_stmt :
AMPLITUDES '=' amplitude_list
{ }
;
type_stmt :
TYPE '=' BANDPASS_FILTER
{ FilterType = BANDPASS; }
| TYPE '=' HILBERT_FILTER
{ FilterType = HILBERT; }
| TYPE '=' DIFFERENTIATOR_FILTER
{ FilterType = DIFFERENTIATOR; }
;
order_stmt :
ORDER '=' REAL
{ Order = int($3 + 0.5); }
;
%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -