⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hys.y

📁 由matlab开发的hybrid系统的描述语言
💻 Y
📖 第 1 页 / 共 3 页
字号:
/*	HYSDEL	Copyright (C) 1999-2002  Fabio D. Torrisi	This file is part of HYSDEL.    	HYSDEL 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.	HYSDEL 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 library; if not, write to the Free Software	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA	CONTACT INFORMATION	===================	Fabio D. Torrisi	ETH Zentrum	Physikstrasse. 3 ETL,	CH-8032 Zurich	Switzerland	mailto:torrisi@aut.ee.ethz.ch (preferred)*//* bison file for hysdel language */ %{ /* C Declarations*/#define yyerror(msg) yysmarterror(msg,yylloc.first_line,((t_parser_input*)p_in)->globals)#include <iostream.h>#include <fstream.h>#include <cctype>#include <cstring>#include <vector>#include <stack>#include <stdio.h>#include <math.h> #include <limits.h>#ifndef DBL_DIG#include <float.h>#endif#include <list>#include <string>#ifndef STD_NS#define STD_NSusing namespace std;#endif#include "And_expr.h"#include "Binary_expr.h"#include "Cast_log2real_expr.h"#include "Cos_expr.h"#include "Div_expr.h"#include "Equivalence_expr.h"#include "Exp_expr.h"#include "Implication_expr.h"#include "Log_expr.h"#include "Minus_expr.h"#include "Mult_expr.h"#include "Neg_expr.h"#include "Not_expr.h"#include "Number_expr.h"#include "Or_expr.h"#include "Parameter_expr.h"#include "Plus_expr.h"#include "Sin_expr.h"#include "Sqrt_expr.h"#include "Terminal_expr.h"#include "Unary_expr.h"#include "Variable_expr.h"#include "Param_symbol.h"#include "Symbol_table.h"#include "Bool_number.h"#include "Implementation.h"#include "MLD_representation.h"#include "Cmd_options.h"#include "Min_max_eps.h"#include "Continuous_section.h"#include "Automata_section.h"#include "Linear_section.h"#include "Logic_section.h"#include "AD_section.h"#include "DA_section.h"#include "Output_section.h"#include "Must_section.h"#include "Continuous_item.h"#include "Automata_item.h"#include "Linear_item.h"#include "Logic_item.h"#include "AD_item.h"#include "DA_item.h"#include "Output_item.h"#include "Cont_output_item.h"#include "Logic_output_item.h"#include "Constraint_item.h"#include "Logic_must_item.h"#include "Cont_must_item.h"#include "Var_symbol.h"#include "Default_symbol.h"#include "Real_number.h"#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"#include "lexer_input.h"#include "parser_input.h"//#define malloc(size) (new char[size]) //#define free(ptr) void yysmarterror(const char * s, int line, const Globals *globals) {	char buf[200];	string msg;		sprintf(buf, "line %d: %s", line, s);	msg=buf;		globals->problem_handler->process(new Problem(ERROR, msg));}void process_system(string*, Implementation*, t_parser_input*);int yyparse(void *p_in);#define YYERROR_VERBOSE /* to get a specific error messages */// define argument to parser to be p_in#define YYPARSE_PARAM p_in// define argument to lexer to be p_in->l_in#define YYLEX_PARAM ((t_parser_input*)p_in)->l_in%}/*Bison declarations*/%pure_parser%union{	int		void_v;  // a dummy	double		 val;		/*For returning numbers */	Implementation  *implementation_v;	/*For implementation*/	string	 *string_v;	const Symbol   *symbol_v;	const Var_symbol *var_symbol_v;	const Param_symbol *param_symbol_v;	const Default_symbol *default_symbol_v;	Expr               *logic_expr_v;	Expr		   *real_expr_v;		Min_max_eps	   *minmaxeps_v;	Section	           *section_v;	list<Section*>     *section_list_v;	Continuous_section      *continuous_section_v; /* UPDATE */	list<Item *>       *continuous_list_v;     /* UPDATE */	Continuous_item         *continuous_item_v;    /* UPDATE */	Automata_section      *automata_section_v; /* AUTOMATA */	list<Item *>       *automata_list_v;     /* AUTOMATA */	Automata_item         *automata_item_v;    /* AUTOMATA */	Output_section      *output_section_v; /* OUTPUT */	list<Item *>       *output_list_v;     /* OUTPUT */	Output_item         *output_item_v;    /* OUTPUT */		Logic_section      *logic_section_v; /* LOGIC */	list<Item *>       *logic_list_v;    /* LOGIC */	Logic_item         *logic_item_v;    /* LOGIC */		Linear_section     *linear_section_v; /* LINEAR */	list<Item *>       *linear_list_v;    /* LINEAR */	Linear_item        *linear_item_v;    /* LINEAR */		DA_section 	   *DA_section_v; /* DA */	list<Item *>       *DA_list_v;    /* DA */	DA_item            *DA_item_v;    /* DA */		AD_section 	   *AD_section_v; /* AD */	list<Item *>       *AD_list_v;    /* AD */	AD_item            *AD_item_v;    /* AD */	Must_section       *must_section_v; /* MUST */	list<Item*>        *must_list_v;    /* MUST */	Constraint_item          *must_item_v;    /* MUST */}%{/** yylex is called from the pure_parser. It cannot be a method. */struct yyltype;int yylex (YYSTYPE *lvalp, struct yyltype *llocp, lexer_input *l_in);%}%token <val>  NUM  /* double precision number */%token <string_v> NEW_IDENTIFIER%token <var_symbol_v> BOOLVARIABLE REALVARIABLE %token <param_symbol_v> NONDEFAULT_PARAMETER%token <default_symbol_v> DEFAULT_PARAMETER%token SYSTEM INTERFACE IMPLEMENTATION	/* KEYWORDS*/%token IF ELSE THEN STATE INPUT		/* KEYWORDS*/%token OUTPUT PARAMETER AUX AD DA	/* KEYWORDS*/%token CONTINUOUS AUTOMATA MUST LOGIC	/* KEYWORDS*/%token LINEAR REAL BOOL TRUE FALSE	/* KEYWORDS*/%token EXP SQRT SIN COS LOG		/* operators on scalarexp*/%type <param_symbol_v> parameter_t%type <string_v> new_ident_t%type <void_v> aux_impl_t%type <void_v> interface_list_t interface_item_t%type <void_v> state_interface_t input_interface_t output_interface_t parameter_interface_t%type <void_v> state_decl_list_t input_decl_list_t output_decl_list_t parameter_decl_list_t aux_decl_list_t%type <void_v> state_decl_t input_decl_t output_decl_t parameter_decl_t aux_decl_t%type <void_v> state_real_ident_list_t state_bool_ident_list_t%type <void_v> input_real_ident_list_t input_bool_ident_list_t%type <void_v> output_real_ident_list_t output_bool_ident_list_t%type <void_v> parameter_real_ident_list_t parameter_bool_ident_list_t%type <void_v> aux_real_ident_list_t aux_bool_ident_list_t%type <void_v> parameter_real_ident_t parameter_bool_ident_t%type <implementation_v> implementation_t system%type <minmaxeps_v>   minmaxeps_t opt_minmaxeps_t var_minmax_t opt_var_minmax_t%type <logic_expr_v>     logic_expr_t%type <real_expr_v>      real_expr_t%type <section_v> section_t%type <section_list_v> section_list_t%type <continuous_section_v> continuous_section_t%type <continuous_list_v>    continuous_list_t%type <continuous_item_v>    continuous_item_t%type <automata_section_v> automata_section_t%type <automata_list_v>    automata_list_t%type <automata_item_v>    automata_item_t%type <output_section_v>  output_section_t%type <output_list_v>     output_list_t%type <output_item_v>     output_item_t, output_logic_t, output_affine_t;%type <logic_section_v> logic_section_t%type <logic_list_v>    logic_list_t%type <logic_item_v>    logic_item_t%type <DA_section_v>    DA_section_t%type <DA_list_v>       DA_list_t%type <DA_item_v>       DA_item_t%type <AD_section_v>    AD_section_t%type <AD_list_v>       AD_list_t%type <AD_item_v>       AD_item_t%type <linear_section_v>linear_section_t%type <linear_list_v>   linear_list_t%type <linear_item_v>   linear_item_t%type <must_section_v>  must_section_t%type <must_list_v>     must_list_t%type <must_item_v>     must_item_t, must_logic_t, must_affine_t;%token LE "<="%token GE ">="%token AR_FI "<-"%token AR_IF "->"%token AR_IFF "<->"%token OR "||"%token AND "&&"%right '='%left '-' '+'%left '*' '/'%left '^'%left UNARY%left '|' "||"%left "<-" "->" "<->"%left '&' "&&"%left '!' '~'%left SCAL/*end bison declarations*/ /******************************************************************************  * Grammar begins                                                             *  ******************************************************************************/%%/******************************************************************************  * Hi level rules                                                             *  ******************************************************************************/system: 	/* empty */		{		}	| SYSTEM new_ident_t '{' interface implementation_t '}' 		{		  process_system($2, $5, ((t_parser_input*)p_in));					};interface:	INTERFACE '{' interface_list_t '}' ;interface_list_t:	interface_list_t interface_item_t {}	| interface_item_t {}	| /*empty*/ {};		interface_item_t:	state_interface_t {}	| input_interface_t {}	| output_interface_t {}	| parameter_interface_t {};implementation_t:	IMPLEMENTATION '{' aux_impl_t section_list_t '}'		{$$ = new Implementation($4, ((t_parser_input*)p_in)->globals)};	section_list_t:	section_t 		{			$$=new list<Section*>();			$$->push_back($1);		}	| section_list_t section_t		{ 			$1->push_back($2);			$$=$1;		};        | /*empty*/ {        		$$=new list<Section*>();		};		section_t:	logic_section_t 		{ $1->propagate_section(); $$=$1; }	| linear_section_t 		{ $1->propagate_section(); $$=$1; }	| AD_section_t		{ $1->propagate_section(); $$=$1; }	| DA_section_t		{ $1->propagate_section(); $$=$1; }	| continuous_section_t		{ $1->propagate_section(); $$=$1; }	| automata_section_t		{ $1->propagate_section(); $$=$1; }	| output_section_t 		{ $1->propagate_section(); $$=$1; }	| must_section_t		{ $1->propagate_section(); $$=$1; };state_interface_t:	STATE '{' state_decl_list_t '}' {};input_interface_t:	INPUT '{' input_decl_list_t '}' {};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -