/[svn]/linuxsampler/trunk/src/network/lscp.y
ViewVC logotype

Annotation of /linuxsampler/trunk/src/network/lscp.y

Parent Directory Parent Directory | Revision Log Revision Log


Revision 214 - (hide annotations) (download)
Sat Aug 14 23:00:44 2004 UTC (19 years, 8 months ago) by schoenebeck
File size: 17929 byte(s)
* src/drivers/DeviceParameter.cpp: fixed return values for
classes 'DeviceRuntimeParameterString' and 'DeviceCreationParameterString'
which returned their values without being encapsulated into apostrophes,
fixed return values for 'DeviceRuntimeParameterBool' and
'DeviceCreationParameterBool' to be returned in lower case (as defined in
the LSCP documentation)
* src/network/lscp.y: key value pairs now also allow strings (without
spaces) to be not encapsulated into apostrophes (e.g. foo=bar instead of
foo='bar')
* src/linuxsampler.cpp: show on the console which TCP port the LSCP server
is using

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 35 * *
7     * This program is free software; you can redistribute it and/or modify *
8     * it under the terms of the GNU General Public License as published by *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23 schoenebeck 210 /* Note: don't forget to run 'make parser' after you changed this file, */
24     /* otherwise the parser will not be regenerated! */
25    
26 schoenebeck 35 %{
27    
28     #include "lscpparser.h"
29     #include "lscpserver.h"
30 senkov 170 #include "lscpevent.h"
31 schoenebeck 35
32     // as we need an reentrant scanner, we have to pass the pointer to the scanner with each yylex() call
33     #define YYLEX_PARAM ((yyparse_param_t*) yyparse_param)->pScanner
34    
35     // to save us typing work in the rules action definitions
36     #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer
37    
38     // clears input buffer and restarts scanner.
39     void restart(yyparse_param_t* pparam, int& yychar);
40     #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar)
41    
42     // external reference to the main scanner function yylex()
43     extern YY_DECL;
44    
45     // external reference to restart the lex scanner
46     extern void yyrestart(FILE* input_file, yyscan_t yyscanner);
47    
48     // we provide our own version of yyerror() so we don't have to link against the yacc library
49     void yyerror(const char* s);
50    
51     %}
52    
53     // reentrant parser
54     %pure_parser
55    
56     %token <Char> CHAR
57     %token <Dotnum> DOTNUM
58     %token <Number> NUMBER
59 senkov 135 %token <String> STRINGVAL
60 schoenebeck 123 %token SP LF CR HASH EQ
61 schoenebeck 210 %token ADD GET CREATE DESTROY LIST LOAD NON_MODAL REMOVE SET SUBSCRIBE UNSUBSCRIBE RESET ECHO QUIT
62 schoenebeck 35 %token CHANNEL NOTIFICATION
63 schoenebeck 123 %token AVAILABLE_ENGINES AVAILABLE_AUDIO_OUTPUT_DRIVERS CHANNELS INFO BUFFER_FILL STREAM_COUNT VOICE_COUNT
64 schoenebeck 35 %token INSTRUMENT ENGINE
65 senkov 155 %token AUDIO_OUTPUT_CHANNEL AUDIO_OUTPUT_CHANNEL_PARAMETER AUDIO_OUTPUT_DEVICE AUDIO_OUTPUT_DEVICES AUDIO_OUTPUT_DEVICE_PARAMETER AUDIO_OUTPUT_DRIVER AUDIO_OUTPUT_DRIVER_PARAMETER AUDIO_OUTPUT_TYPE MIDI_INPUT MIDI_INPUT_TYPE MIDI_INPUT_PORT MIDI_INPUT_CHANNEL VOLUME
66     %token MIDI_INPUT_DRIVER MIDI_INPUT_DRIVER_PARAMETER AVAILABLE_MIDI_INPUT_DRIVERS MIDI_INPUT_DEVICE MIDI_INPUT_DEVICES MIDI_INPUT_DEVICE_PARAMETER MIDI_INPUT_PORT_PARAMETER
67 schoenebeck 35 %token BYTES PERCENTAGE
68 senkov 135 %token MISCELLANEOUS
69 schoenebeck 35
70 schoenebeck 210 %type <Dotnum> volume boolean
71 capela 159 %type <Number> sampler_channel instrument_index audio_output_channel audio_output_device midi_input_channel midi_input_port midi_input_device
72 senkov 155 %type <String> string param_val filename engine_name command create_instruction destroy_instruction get_instruction list_instruction load_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type midi_input_type set_instruction subscribe_event unsubscribe_event
73 schoenebeck 35 %type <FillResponse> buffer_size_type
74 schoenebeck 123 %type <KeyValList> key_val_list
75 schoenebeck 35
76     %start input
77    
78     %%
79    
80     //TODO: return more meaningful error messages
81    
82 senkov 170 input : line LF
83 schoenebeck 35
84 senkov 170 line : /* epsilon (empty line ignored) */ { return LSCP_DONE; }
85     | comment { return LSCP_DONE; }
86     | command { LSCPSERVER->AnswerClient($1); return LSCP_DONE; }
87 schoenebeck 35 | error { LSCPSERVER->AnswerClient("Err:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; }
88     ;
89    
90 schoenebeck 111 comment : HASH
91     | comment HASH
92     | comment SP
93     | comment NUMBER
94     | comment string
95     ;
96    
97 schoenebeck 35 command : ADD SP CHANNEL { $$ = LSCPSERVER->AddChannel(); }
98     | GET SP get_instruction { $$ = $3; }
99 schoenebeck 123 | CREATE SP create_instruction { $$ = $3; }
100     | DESTROY SP destroy_instruction { $$ = $3; }
101     | LIST SP list_instruction { $$ = $3; }
102 senkov 141 | LOAD SP load_instruction { $$ = $3; }
103 schoenebeck 35 | REMOVE SP CHANNEL SP sampler_channel { $$ = LSCPSERVER->RemoveChannel($5); }
104 schoenebeck 123 | SET SP set_instruction { $$ = $3; }
105 senkov 135 | SUBSCRIBE SP subscribe_event { $$ = $3; }
106     | UNSUBSCRIBE SP unsubscribe_event { $$ = $3; }
107 schoenebeck 35 | RESET SP CHANNEL SP sampler_channel { $$ = LSCPSERVER->ResetChannel($5); }
108 schoenebeck 212 | RESET { $$ = LSCPSERVER->ResetSampler(); }
109 senkov 170 | QUIT { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }
110 schoenebeck 35 ;
111    
112 senkov 170 subscribe_event : CHANNELS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channels); }
113     | VOICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); }
114     | STREAM_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); }
115     | BUFFER_FILL { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); }
116     | INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_info); }
117     | MISCELLANEOUS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); }
118 senkov 135 ;
119    
120 senkov 170 unsubscribe_event : CHANNELS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channels); }
121     | VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); }
122     | STREAM_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); }
123     | BUFFER_FILL { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); }
124     | INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_info); }
125     | MISCELLANEOUS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); }
126 senkov 135 ;
127    
128 senkov 170 get_instruction : AVAILABLE_ENGINES { $$ = LSCPSERVER->GetAvailableEngines(); }
129     | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->GetAvailableMidiInputDrivers(); }
130     | MIDI_INPUT_DRIVER SP INFO SP string { $$ = LSCPSERVER->GetMidiInputDriverInfo($5); }
131     | MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7); }
132     | MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7, $9); }
133     | AVAILABLE_AUDIO_OUTPUT_DRIVERS { $$ = LSCPSERVER->GetAvailableAudioOutputDrivers(); }
134     | AUDIO_OUTPUT_DRIVER SP INFO SP string { $$ = LSCPSERVER->GetAudioOutputDriverInfo($5); }
135     | AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7); }
136     | AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7, $9); }
137     | AUDIO_OUTPUT_DEVICES { $$ = LSCPSERVER->GetAudioOutputDeviceCount(); }
138     | MIDI_INPUT_DEVICES { $$ = LSCPSERVER->GetMidiInputDeviceCount(); }
139     | AUDIO_OUTPUT_DEVICE SP INFO SP NUMBER { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5); }
140     | MIDI_INPUT_DEVICE SP INFO SP NUMBER { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5); }
141     | MIDI_INPUT_PORT SP INFO SP NUMBER SP NUMBER { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7); }
142 senkov 185 | MIDI_INPUT_PORT_PARAMETER SP INFO SP NUMBER SP NUMBER SP string { $$ = LSCPSERVER->GetMidiInputPortParameterInfo($5, $7, $9); }
143 senkov 170 | AUDIO_OUTPUT_CHANNEL SP INFO SP NUMBER SP NUMBER { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7); }
144     | AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP NUMBER SP NUMBER SP string { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9); }
145     | CHANNELS { $$ = LSCPSERVER->GetChannels(); }
146     | CHANNEL SP INFO SP sampler_channel { $$ = LSCPSERVER->GetChannelInfo($5); }
147     | CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel { $$ = LSCPSERVER->GetBufferFill($5, $7); }
148     | CHANNEL SP STREAM_COUNT SP sampler_channel { $$ = LSCPSERVER->GetStreamCount($5); }
149     | CHANNEL SP VOICE_COUNT SP sampler_channel { $$ = LSCPSERVER->GetVoiceCount($5); }
150     | ENGINE SP INFO SP engine_name { $$ = LSCPSERVER->GetEngineInfo($5); }
151 schoenebeck 35 ;
152    
153 senkov 170 set_instruction : AUDIO_OUTPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7); }
154     | AUDIO_OUTPUT_CHANNEL_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); }
155     | MIDI_INPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7); }
156     | MIDI_INPUT_PORT_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9); }
157 senkov 155 | CHANNEL SP set_chan_instruction { $$ = $3; }
158 schoenebeck 210 | ECHO SP boolean { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3); }
159 schoenebeck 123 ;
160    
161 senkov 135 create_instruction : AUDIO_OUTPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }
162 capela 159 | AUDIO_OUTPUT_DEVICE SP string { $$ = LSCPSERVER->CreateAudioOutputDevice($3); }
163     | MIDI_INPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateMidiInputDevice($3,$5); }
164     | MIDI_INPUT_DEVICE SP string { $$ = LSCPSERVER->CreateMidiInputDevice($3); }
165 schoenebeck 123 ;
166    
167 senkov 170 destroy_instruction : AUDIO_OUTPUT_DEVICE SP NUMBER { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); }
168     | MIDI_INPUT_DEVICE SP NUMBER { $$ = LSCPSERVER->DestroyMidiInputDevice($3); }
169 schoenebeck 123 ;
170    
171 schoenebeck 35 load_instruction : INSTRUMENT SP load_instr_args { $$ = $3; }
172     | ENGINE SP load_engine_args { $$ = $3; }
173     ;
174    
175 capela 159 set_chan_instruction : AUDIO_OUTPUT_DEVICE SP sampler_channel SP audio_output_device { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3); }
176 schoenebeck 123 | AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_output_channel SP audio_output_channel { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }
177 capela 143 | AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type { $$ = LSCPSERVER->SetAudioOutputType($5, $3); }
178 capela 159 | MIDI_INPUT SP sampler_channel SP midi_input_device SP midi_input_port SP midi_input_channel { $$ = LSCPSERVER->SetMIDIInput($5, $7, $9, $3); }
179     | MIDI_INPUT_DEVICE SP sampler_channel SP midi_input_device { $$ = LSCPSERVER->SetMIDIInputDevice($5, $3); }
180     | MIDI_INPUT_PORT SP sampler_channel SP midi_input_port { $$ = LSCPSERVER->SetMIDIInputPort($5, $3); }
181     | MIDI_INPUT_CHANNEL SP sampler_channel SP midi_input_channel { $$ = LSCPSERVER->SetMIDIInputChannel($5, $3); }
182 schoenebeck 123 | MIDI_INPUT_TYPE SP sampler_channel SP midi_input_type { $$ = LSCPSERVER->SetMIDIInputType($5, $3); }
183     | VOLUME SP sampler_channel SP volume { $$ = LSCPSERVER->SetVolume($5, $3); }
184 schoenebeck 35 ;
185    
186 senkov 135 key_val_list : string EQ param_val { $$[$1] = $3; }
187     | key_val_list SP string EQ param_val { $$ = $1; $$[$3] = $5; }
188     ;
189 schoenebeck 123
190 schoenebeck 35 buffer_size_type : BYTES { $$ = fill_response_bytes; }
191     | PERCENTAGE { $$ = fill_response_percentage; }
192     ;
193    
194 schoenebeck 209 list_instruction : AUDIO_OUTPUT_DEVICES { $$ = LSCPSERVER->GetAudioOutputDevices(); }
195     | MIDI_INPUT_DEVICES { $$ = LSCPSERVER->GetMidiInputDevices(); }
196     | CHANNELS { $$ = LSCPSERVER->ListChannels(); }
197 schoenebeck 123 ;
198    
199 senkov 170 load_instr_args : filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); }
200     | NON_MODAL SP filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true); }
201 schoenebeck 35 ;
202    
203 senkov 170 load_engine_args : engine_name SP sampler_channel { $$ = LSCPSERVER->LoadEngine($1, $3); }
204 schoenebeck 35 ;
205    
206 capela 159 audio_output_device : NUMBER
207     ;
208    
209     audio_output_channel : NUMBER
210     ;
211    
212 capela 143 audio_output_type : string
213     ;
214    
215 senkov 155 midi_input_device : NUMBER
216     ;
217    
218     midi_input_port : NUMBER
219     ;
220    
221     midi_input_channel : NUMBER
222     ;
223    
224 schoenebeck 123 midi_input_type : string
225 schoenebeck 35 ;
226    
227     volume : DOTNUM
228     | NUMBER { $$ = $1; }
229     ;
230    
231     sampler_channel : NUMBER
232     ;
233    
234     instrument_index : NUMBER
235     ;
236    
237     engine_name : string
238     ;
239    
240 senkov 135 filename : STRINGVAL
241 schoenebeck 35 ;
242    
243 schoenebeck 214 param_val : string
244     | STRINGVAL
245 schoenebeck 35 | NUMBER { std::stringstream ss; ss << $1; $$ = ss.str(); }
246 senkov 135 | DOTNUM { std::stringstream ss; ss << $1; $$ = ss.str(); }
247 schoenebeck 35 ;
248    
249 schoenebeck 210 boolean : NUMBER { $$ = $1; }
250     | string { $$ = -1; }
251     ;
252    
253 schoenebeck 35 string : CHAR { std::string s; s = $1; $$ = s; }
254     | string CHAR { $$ = $1 + $2; }
255     ;
256    
257     %%
258    
259     /**
260     * Will be called when an error occured (usually syntax error).
261     */
262     void yyerror(const char* s) {
263     dmsg(2,("LSCPParser: %s\n", s));
264     }
265    
266     /**
267     * Clears input buffer and restarts scanner.
268     */
269     void restart(yyparse_param_t* pparam, int& yychar) {
270     // restart scanner
271     yyrestart(stdin, pparam->pScanner);
272     // reset lookahead symbol
273     yyclearin;
274     }

  ViewVC Help
Powered by ViewVC