📄 hys.l
字号:
/* 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)*/%option noyywrap%option yylineno%option c++%option yyclass="Pure_lexer"%x comment%{#include <string>#include <ctype.h>#include <stdio.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 "Param_symbol.h"#include "Symbol_table.h"#include "Symbol.h"#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"//"hys.tab.h" is included in "Pure_lexer.h"#include "Pure_lexer.h"#define malloc(size) (new char[size]) #define free(ptr) %}%% [[:blank:]]+ { /* empty */;}\n {}"/*" { BEGIN(comment);}<comment>[^*\n]* { /* eat anything that is not a star */}<comment>"*"+[^*/] { /* eat '*' not followed by '/'s */}<comment>\n {}<comment>"*"+"/" { BEGIN(INITIAL);}<<EOF>> { return 0;}[[:digit:]]*[\.[:digit:]][[:digit:]]*("E"|"e"("-"|"+")?[[:digit:]]+)? { sscanf(YYText(), "%lf", & (lvalp->val)); return NUM; /* NUM is defined in bison */}">=" { return GE;}"<=" { return LE;}"<-" { return AR_FI;}"->" { return AR_IF;}"<->" { return AR_IFF;}"||" { return OR;}"&&" { return AND;}"SYSTEM" { llocp->first_line=yylineno; return SYSTEM;}"INTERFACE" { llocp->first_line=yylineno; return INTERFACE;}"IMPLEMENTATION" { llocp->first_line=yylineno; return IMPLEMENTATION;}"IF" { llocp->first_line=yylineno; return IF;}"ELSE" { llocp->first_line=yylineno; return ELSE;}"STATE" { llocp->first_line=yylineno; return STATE;}"INPUT" { llocp->first_line=yylineno; return INPUT;}"OUTPUT" { llocp->first_line=yylineno; return OUTPUT;}"PARAMETER" { llocp->first_line=yylineno; return PARAMETER;}"AUX" { llocp->first_line=yylineno; return AUX;}"AD" { llocp->first_line=yylineno; return AD;}"DA" { llocp->first_line=yylineno; return DA;}"CONTINUOUS" { llocp->first_line=yylineno; return CONTINUOUS;}"MUST" { llocp->first_line=yylineno; return MUST;}"LOGIC" { llocp->first_line=yylineno; return LOGIC;}"LINEAR" { llocp->first_line=yylineno; return LINEAR;}"REAL" { llocp->first_line=yylineno; return REAL;}"BOOL" { llocp->first_line=yylineno; return BOOL;}"THEN" { llocp->first_line=yylineno; return THEN;}"AUTOMATA" { llocp->first_line=yylineno; return AUTOMATA;}"TRUE" { llocp->first_line=yylineno; return TRUE;}"FALSE" { llocp->first_line=yylineno; return FALSE;}"cos" { llocp->first_line=yylineno; return COS;}"exp" { llocp->first_line=yylineno; return EXP;}"log" { llocp->first_line=yylineno; return LOG;}"sin" { llocp->first_line=yylineno; return SIN;}"sqrt" { llocp->first_line=yylineno; return SQRT;}[[:alpha:]][[:alnum:]_]* { const Symbol * s;assert(globals);assert(globals->symbol_table); s = globals->symbol_table->find_symbol(YYText()); llocp->first_line=yylineno; if (!s) { /* not found */ lvalp->string_v = new string(YYText(), YYLeng()); return NEW_IDENTIFIER; } else { /* string found* */ if (s->get_kind() == PARAM_KIND) { if (s->is_default_symbol()) { lvalp->default_symbol_v=(const Default_symbol*)s; return DEFAULT_PARAMETER; } else { lvalp->param_symbol_v=(const Param_symbol*)s; return NONDEFAULT_PARAMETER; } } else if (s->get_type() == REAL_TYPE) { lvalp->var_symbol_v=(const Var_symbol*)s; return REALVARIABLE; } else { lvalp->var_symbol_v=(const Var_symbol*)s; return BOOLVARIABLE; } }}[[:alpha:]][[:alnum:]_\.:]* { /* old style identifiers are now forbidden!! */ string msg; char buf[50]; sprintf(buf, "line %d: ", lineno()); msg = buf; msg += string("bad identifier name"); globals->problem_handler->process(new Problem(ERROR, msg)); }. { return *YYText();}%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -