1 |
schoenebeck |
35 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
schoenebeck |
56 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
schoenebeck |
2510 |
* Copyright (C) 2005 - 2014 Christian Schoenebeck * |
7 |
schoenebeck |
35 |
* * |
8 |
|
|
* This program is free software; you can redistribute it and/or modify * |
9 |
|
|
* it under the terms of the GNU General Public License as published by * |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
11 |
|
|
* (at your option) any later version. * |
12 |
|
|
* * |
13 |
|
|
* This program is distributed in the hope that it will be useful, * |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
|
|
* GNU General Public License for more details. * |
17 |
|
|
* * |
18 |
|
|
* You should have received a copy of the GNU General Public License * |
19 |
|
|
* along with this program; if not, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
|
|
#ifndef __LSCPPARSER_H__ |
25 |
|
|
#define __LSCPPARSER_H__ |
26 |
|
|
|
27 |
|
|
#include <sys/types.h> |
28 |
senoner |
1481 |
#if defined(WIN32) |
29 |
|
|
#include <windows.h> |
30 |
|
|
#else |
31 |
schoenebeck |
35 |
#include <sys/socket.h> |
32 |
senoner |
1481 |
#endif |
33 |
schoenebeck |
35 |
|
34 |
|
|
#include <stdlib.h> |
35 |
|
|
#include <iostream> |
36 |
|
|
#include <sstream> |
37 |
|
|
#include <string> |
38 |
schoenebeck |
2510 |
#include <stdint.h> |
39 |
|
|
#include <set> |
40 |
schoenebeck |
35 |
|
41 |
schoenebeck |
1424 |
#include "../common/global_private.h" |
42 |
schoenebeck |
1332 |
#include "../common/Path.h" |
43 |
senkov |
170 |
#include "lscpevent.h" |
44 |
schoenebeck |
53 |
#include "../Sampler.h" |
45 |
schoenebeck |
947 |
#include "../drivers/midi/MidiInstrumentMapper.h" |
46 |
schoenebeck |
35 |
|
47 |
persson |
1765 |
namespace LinuxSampler { |
48 |
|
|
|
49 |
schoenebeck |
35 |
/// Will be returned by the parser in case of syntax errors. |
50 |
|
|
#define LSCP_SYNTAX_ERROR -69 |
51 |
senkov |
170 |
#define LSCP_QUIT -1 |
52 |
|
|
#define LSCP_DONE 0 |
53 |
schoenebeck |
35 |
|
54 |
senkov |
170 |
// just symbol prototyping |
55 |
|
|
class LSCPServer; |
56 |
|
|
|
57 |
schoenebeck |
35 |
/** |
58 |
|
|
* How the fill states of disk stream buffers should be reflected. |
59 |
|
|
*/ |
60 |
|
|
enum fill_response_t { |
61 |
|
|
fill_response_bytes, ///< The returned values are meant in bytes. |
62 |
|
|
fill_response_percentage ///< The returned values are meant in percentage. |
63 |
|
|
}; |
64 |
|
|
|
65 |
|
|
/** |
66 |
|
|
* Semantic value of the lookahead symbol. |
67 |
|
|
* |
68 |
|
|
* Structure that is used by the parser to process and return values from the |
69 |
|
|
* input text. The lexical analyzer for example returns a number for |
70 |
|
|
* recognized number strings in the input text and the parser might return a |
71 |
|
|
* value for each of it's rules. |
72 |
|
|
*/ |
73 |
schoenebeck |
1244 |
struct _YYSTYPE { |
74 |
schoenebeck |
35 |
union { |
75 |
schoenebeck |
947 |
char Char; |
76 |
|
|
unsigned int Number; |
77 |
schoenebeck |
1047 |
bool Bool; |
78 |
schoenebeck |
947 |
double Dotnum; |
79 |
|
|
fill_response_t FillResponse; |
80 |
|
|
LSCPEvent::event_t Event; |
81 |
|
|
MidiInstrumentMapper::mode_t LoadMode; |
82 |
schoenebeck |
35 |
}; |
83 |
schoenebeck |
123 |
std::string String; |
84 |
|
|
std::map<std::string,std::string> KeyValList; |
85 |
schoenebeck |
1332 |
Path UniversalPath; |
86 |
schoenebeck |
35 |
}; |
87 |
schoenebeck |
1244 |
#define YYSTYPE _YYSTYPE |
88 |
schoenebeck |
35 |
#define yystype YYSTYPE ///< For backward compatibility. |
89 |
|
|
#define YYSTYPE_IS_DECLARED ///< We tell the lexer / parser that we use our own data structure as defined above. |
90 |
schoenebeck |
2510 |
#define YYTYPE_INT16 int16_t |
91 |
schoenebeck |
35 |
|
92 |
|
|
/** |
93 |
|
|
* Parameters given to the parser on every yyparse() call. |
94 |
|
|
*/ |
95 |
|
|
struct yyparse_param_t { |
96 |
|
|
LSCPServer* pServer; |
97 |
schoenebeck |
210 |
int hSession; |
98 |
|
|
bool bVerbose; ///< if true then all commands will immediately sent back (echo) |
99 |
schoenebeck |
2515 |
bool bShellInteract; ///< if true: then client is the LSCP shell |
100 |
schoenebeck |
1252 |
int iLine; ///< Current line (just for verbosity / messages) |
101 |
|
|
int iColumn; ///< Current column (just for verbosity / messages) |
102 |
schoenebeck |
2510 |
YYTYPE_INT16** ppStackBottom; ///< Bottom end of the Bison parser's state stack. |
103 |
|
|
YYTYPE_INT16** ppStackTop; ///< Current position (heap) of the Bison parser's state stack. |
104 |
schoenebeck |
210 |
|
105 |
|
|
yyparse_param_t() { |
106 |
|
|
pServer = NULL; |
107 |
|
|
hSession = -1; |
108 |
|
|
bVerbose = false; |
109 |
schoenebeck |
2515 |
bShellInteract = false; |
110 |
schoenebeck |
1252 |
iLine = iColumn = 0; |
111 |
schoenebeck |
2510 |
ppStackBottom = ppStackTop = NULL; |
112 |
schoenebeck |
210 |
} |
113 |
schoenebeck |
35 |
}; |
114 |
|
|
#define YYPARSE_PARAM yyparse_param |
115 |
|
|
|
116 |
|
|
/** |
117 |
|
|
* Prototype of the main scanner function (lexical analyzer). |
118 |
|
|
*/ |
119 |
schoenebeck |
219 |
#define YY_DECL int yylex(YYSTYPE* yylval) |
120 |
schoenebeck |
35 |
|
121 |
persson |
1765 |
} |
122 |
|
|
|
123 |
schoenebeck |
35 |
#endif // __LSCPPARSER_H__ |