0031740: Configuration - recover support of Yacc and Lex generation
[occt.git] / src / ExprIntrp / ExprIntrp.lex
CommitLineData
61043d3f 1/*
2
3 Copyright (c) 1997-1999 Matra Datavision
973c2be1 4 Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5
973c2be1 6 This file is part of Open CASCADE Technology software library.
b311480e 7
d5f74e42 8 This library is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10 by the Free Software Foundation, with special exception defined in the file
11 OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 distribution for complete text of the license and disclaimer of any warranty.
b311480e 13
973c2be1 14 Alternatively, this file may be used under the terms of Open CASCADE
15 commercial license or contractual agreement.
b311480e 16*/
17
7fd59977 18%option yywrap
19%{
20#include <ExprIntrp.tab.h>
105aae76 21
2a54ebbf 22#include <ExprIntrp_yaccintrf.hxx>
23
7fd59977 24#define YY_SKIP_YYWRAP
25
26static YY_BUFFER_STATE ExprIntrp_bufstring;
27
2a54ebbf 28void ExprIntrp_start_string(const char* str)
7fd59977 29{
2a54ebbf 30 // depending on configuration and generator, yyconst may be defined as const or empty
31 ExprIntrp_bufstring = ExprIntrp_scan_string((yyconst char*)str);
7fd59977 32}
33
34void ExprIntrp_stop_string()
35{
36 ExprIntrp_delete_buffer(ExprIntrp_bufstring);
9fe1ada8 37 ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
7fd59977 38}
39
2a54ebbf 40static int yywrap()
7fd59977 41{
42 return 1;
43}
44
2a54ebbf 45// provide safe error handler (exception instead of exit())
46#define YY_FATAL_ERROR(msg) ExprIntrperror(msg)
47
fba34cf8 48// MSVC specifics
105aae76 49#ifdef _MSC_VER
fba34cf8 50
61043d3f 51// add includes for flex 2.91 (Linux version)
52#include <stdlib.h>
53#include <io.h>
54
f58f9b92 55// Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
56#define YY_NO_UNISTD_H
57
2a54ebbf 58// disable MSVC warnings in flex 2.89 and 2.5.35 code
59// Note that Intel compiler also defines _MSC_VER but has different warning ids
60#if defined(__INTEL_COMPILER)
61#pragma warning(disable:177 1786 1736)
1bd04b5a 62#elif defined(__clang__)
63#pragma GCC diagnostic ignored "-Wunused-function"
64#pragma GCC diagnostic ignored "-Winconsistent-dllimport"
65#pragma GCC diagnostic ignored "-Wunneeded-internal-declaration"
2a54ebbf 66#else
67#pragma warning(disable:4131 4244 4273 4127 4267)
68#endif
69
fba34cf8 70#endif /* MSC_VER */
105aae76 71
61043d3f 72#ifdef __GNUC__
73// add includes for flex 2.91 (Linux version)
74#include <unistd.h>
75
76// disable GCC warnings in flex 2.91 code
77#pragma GCC diagnostic ignored "-Wunused-function"
78#endif
79
7fd59977 80%}
81%%
82" " {;}
83"+" {return(SUMOP) ;}
84"-" {return(MINUSOP) ;}
85"/" {return(DIVIDEOP) ;}
86"^" {return(EXPOP) ;}
87"**" {return(EXPOP) ;}
88"*" {return(MULTOP) ;}
89"(" {return(PARENTHESIS);}
90"[" {return(BRACKET);}
91")" {return(ENDPARENTHESIS);}
92"]" {return(ENDBRACKET);}
93"," {return(COMMA);}
94"@" {return(DIFFERENTIAL);}
95"<-" {return(ASSIGNOP);}
96"=" {return(EQUALOP);}
97"Deassign" {return(DEASSIGNKEY);}
98"Deriv" {return(DERIVKEY);}
99"Const" {return(CONSTKEY);}
100"Sum" {return(SUMKEY);}
101"Prod" {return(PRODKEY);}
102[0-9.]+e[+|-]?[0-9]+ {ExprIntrp_SetResult(); return(VALUE);}
103[0-9.]+ {ExprIntrp_SetResult(); return(VALUE);}
104[a-zA-Z][a-zA-Z0-9_]* {ExprIntrp_SetResult(); return(IDENTIFIER);}
105";" {return(RELSEPARATOR);}
106"'"+ {ExprIntrp_SetDegree();return(DERIVATE);}