mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-06-20 11:54:07 +03:00
Scripts adm/cmake/bison.cmake and adm/cmake/flex.cmake are refactored to enable actual search for bison and flex. Apart of standard locations, also sub-folders of 3RDPARTY_DIR whose names contain "bison" and "flex", respectively, are added to search. Cache variables 3RDPARTY_BISON_EXECUTABLE and 3RDPARTY_FLEX_EXECUTABLE are removed to avoid confusion (they duplicated similar variables without "3RDPARTY_" prefix). Lex and Yacc files are corrected to match changes made manually in generated files during last years: - StepFile/step.yacc: correction missing from #22972 - StepFile/step.lex: corrected for compilation (broken by #31060) - MSVC-specific code is synchronized between StepFile/step.lex and ExprIntrp/ExprIntrp.lex - Old commented code and duplicate code blocks removed Commands for execution of Flex and Bison tools in CMake scripts are tweaked to avoid embedding line numbers (with local paths) in generated files. Scanners and parsers are regenerated from updated source files with modified options. Note that lex.ExprIntrp.c is regenerated with multiple differences because option -f (fast scanner) was used for generation of previous version (by WOK).
107 lines
2.9 KiB
Plaintext
107 lines
2.9 KiB
Plaintext
/*
|
|
|
|
Copyright (c) 1997-1999 Matra Datavision
|
|
Copyright (c) 1999-2014 OPEN CASCADE SAS
|
|
|
|
This file is part of Open CASCADE Technology software library.
|
|
|
|
This library is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU Lesser General Public License version 2.1 as published
|
|
by the Free Software Foundation, with special exception defined in the file
|
|
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
|
distribution for complete text of the license and disclaimer of any warranty.
|
|
|
|
Alternatively, this file may be used under the terms of Open CASCADE
|
|
commercial license or contractual agreement.
|
|
*/
|
|
|
|
%option yywrap
|
|
%{
|
|
#include <ExprIntrp.tab.h>
|
|
|
|
#include <ExprIntrp_yaccintrf.hxx>
|
|
|
|
#define YY_SKIP_YYWRAP
|
|
|
|
static YY_BUFFER_STATE ExprIntrp_bufstring;
|
|
|
|
void ExprIntrp_start_string(const char* str)
|
|
{
|
|
// depending on configuration and generator, yyconst may be defined as const or empty
|
|
ExprIntrp_bufstring = ExprIntrp_scan_string((yyconst char*)str);
|
|
}
|
|
|
|
void ExprIntrp_stop_string()
|
|
{
|
|
ExprIntrp_delete_buffer(ExprIntrp_bufstring);
|
|
ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
|
|
}
|
|
|
|
static int yywrap()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
// provide safe error handler (exception instead of exit())
|
|
#define YY_FATAL_ERROR(msg) ExprIntrperror(msg)
|
|
|
|
// MSVC specifics
|
|
#ifdef _MSC_VER
|
|
|
|
// add includes for flex 2.91 (Linux version)
|
|
#include <stdlib.h>
|
|
#include <io.h>
|
|
|
|
// Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
|
|
#define YY_NO_UNISTD_H
|
|
|
|
// disable MSVC warnings in flex 2.89 and 2.5.35 code
|
|
// Note that Intel compiler also defines _MSC_VER but has different warning ids
|
|
#if defined(__INTEL_COMPILER)
|
|
#pragma warning(disable:177 1786 1736)
|
|
#elif defined(__clang__)
|
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
|
#pragma GCC diagnostic ignored "-Winconsistent-dllimport"
|
|
#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
|
|
#else
|
|
#pragma warning(disable:4131 4244 4273 4127 4267)
|
|
#endif
|
|
|
|
#endif /* MSC_VER */
|
|
|
|
#ifdef __GNUC__
|
|
// add includes for flex 2.91 (Linux version)
|
|
#include <unistd.h>
|
|
|
|
// disable GCC warnings in flex 2.91 code
|
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
|
#endif
|
|
|
|
%}
|
|
%%
|
|
" " {;}
|
|
"+" {return(SUMOP) ;}
|
|
"-" {return(MINUSOP) ;}
|
|
"/" {return(DIVIDEOP) ;}
|
|
"^" {return(EXPOP) ;}
|
|
"**" {return(EXPOP) ;}
|
|
"*" {return(MULTOP) ;}
|
|
"(" {return(PARENTHESIS);}
|
|
"[" {return(BRACKET);}
|
|
")" {return(ENDPARENTHESIS);}
|
|
"]" {return(ENDBRACKET);}
|
|
"," {return(COMMA);}
|
|
"@" {return(DIFFERENTIAL);}
|
|
"<-" {return(ASSIGNOP);}
|
|
"=" {return(EQUALOP);}
|
|
"Deassign" {return(DEASSIGNKEY);}
|
|
"Deriv" {return(DERIVKEY);}
|
|
"Const" {return(CONSTKEY);}
|
|
"Sum" {return(SUMKEY);}
|
|
"Prod" {return(PRODKEY);}
|
|
[0-9.]+e[+|-]?[0-9]+ {ExprIntrp_SetResult(); return(VALUE);}
|
|
[0-9.]+ {ExprIntrp_SetResult(); return(VALUE);}
|
|
[a-zA-Z][a-zA-Z0-9_]* {ExprIntrp_SetResult(); return(IDENTIFIER);}
|
|
";" {return(RELSEPARATOR);}
|
|
"'"+ {ExprIntrp_SetDegree();return(DERIVATE);}
|