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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 53 by schoenebeck, Mon Apr 26 17:15:51 2004 UTC revision 209 by schoenebeck, Sun Jul 18 00:29:39 2004 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck         *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *                                                                         *   *                                                                         *
7   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 24  Line 24 
24    
25  #include "lscpparser.h"  #include "lscpparser.h"
26  #include "lscpserver.h"  #include "lscpserver.h"
27    #include "lscpevent.h"
28    
29  // as we need an reentrant scanner, we have to pass the pointer to the scanner with each yylex() call  // as we need an reentrant scanner, we have to pass the pointer to the scanner with each yylex() call
30  #define YYLEX_PARAM ((yyparse_param_t*) yyparse_param)->pScanner  #define YYLEX_PARAM ((yyparse_param_t*) yyparse_param)->pScanner
# Line 52  void yyerror(const char* s); Line 53  void yyerror(const char* s);
53  %token <Char>   CHAR  %token <Char>   CHAR
54  %token <Dotnum> DOTNUM  %token <Dotnum> DOTNUM
55  %token <Number> NUMBER  %token <Number> NUMBER
56  %token SP LF CR  %token <String> STRINGVAL
57  %token ADD GET LOAD REMOVE SET SUBSCRIBE UNSUBSCRIBE RESET QUIT  %token SP LF CR HASH EQ
58    %token ADD GET CREATE DESTROY LIST LOAD NON_MODAL REMOVE SET SUBSCRIBE UNSUBSCRIBE RESET QUIT
59  %token CHANNEL NOTIFICATION  %token CHANNEL NOTIFICATION
60  %token AVAILABLE_ENGINES CHANNELS INFO BUFFER_FILL STREAM_COUNT VOICE_COUNT  %token AVAILABLE_ENGINES AVAILABLE_AUDIO_OUTPUT_DRIVERS CHANNELS INFO BUFFER_FILL STREAM_COUNT VOICE_COUNT
61  %token INSTRUMENT ENGINE  %token INSTRUMENT ENGINE
62  %token AUDIO_OUTPUT_CHANNEL AUDIO_OUTPUT_TYPE MIDI_INPUT_PORT MIDI_INPUT_CHANNEL MIDI_INPUT_TYPE VOLUME  %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
63    %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
64  %token BYTES PERCENTAGE  %token BYTES PERCENTAGE
65  %token ALSA JACK  %token MISCELLANEOUS
66    
67  %type <Dotnum> volume  %type <Dotnum> volume
68  %type <Number> sampler_channel instrument_index udp_port audio_output_channel midi_input_channel  %type <Number> sampler_channel instrument_index audio_output_channel audio_output_device midi_input_channel midi_input_port midi_input_device
69  %type <String> string alpha_num_string filename engine_name session_id midi_input_port command get_instruction load_instruction set_chan_instruction load_instr_args load_engine_args  %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
70  %type <FillResponse> buffer_size_type  %type <FillResponse> buffer_size_type
71  %type <AudioOutput> audio_output_type  %type <KeyValList> key_val_list
 %type <MidiInput> midi_input_type  
72    
73  %start input  %start input
74    
# Line 74  void yyerror(const char* s); Line 76  void yyerror(const char* s);
76    
77  //TODO: return more meaningful error messages  //TODO: return more meaningful error messages
78    
79  input                 :  line  input                 : line LF
                       |  input LF line  
                       |  input CR LF line  
                       ;  
80    
81  line                  :  /* epsilon (empty line ignored) */  line                  :  /* epsilon (empty line ignored) */ { return LSCP_DONE; }
82                        |  command  { LSCPSERVER->AnswerClient($1); }                        |  comment  { return LSCP_DONE; }
83                          |  command  { LSCPSERVER->AnswerClient($1); return LSCP_DONE; }
84                        |  error    { LSCPSERVER->AnswerClient("Err:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; }                        |  error    { LSCPSERVER->AnswerClient("Err:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; }
85                        ;                        ;
86    
87    comment               :  HASH
88                          |  comment HASH
89                          |  comment SP
90                          |  comment NUMBER
91                          |  comment string
92                          ;
93    
94  command               :  ADD SP CHANNEL                             { $$ = LSCPSERVER->AddChannel();                  }  command               :  ADD SP CHANNEL                             { $$ = LSCPSERVER->AddChannel();                  }
95                        |  GET SP get_instruction                     { $$ = $3;                                        }                        |  GET SP get_instruction                     { $$ = $3;                                        }
96                          |  CREATE SP create_instruction               { $$ = $3;                                        }
97                          |  DESTROY SP destroy_instruction             { $$ = $3;                                        }
98                          |  LIST SP list_instruction                   { $$ = $3;                                        }
99                        |  LOAD SP load_instruction                   { $$ = $3;                                        }                        |  LOAD SP load_instruction                   { $$ = $3;                                        }
100                        |  REMOVE SP CHANNEL SP sampler_channel       { $$ = LSCPSERVER->RemoveChannel($5);             }                        |  REMOVE SP CHANNEL SP sampler_channel       { $$ = LSCPSERVER->RemoveChannel($5);             }
101                        |  SET SP CHANNEL SP set_chan_instruction     { $$ = $5;                                        }                        |  SET SP set_instruction                     { $$ = $3;                                        }
102                        |  SUBSCRIBE SP NOTIFICATION SP udp_port      { $$ = LSCPSERVER->SubscribeNotification($5);     }                        |  SUBSCRIBE SP subscribe_event               { $$ = $3;                                        }
103                        |  UNSUBSCRIBE SP NOTIFICATION SP session_id  { $$ = LSCPSERVER->UnsubscribeNotification($5);   }                        |  UNSUBSCRIBE SP unsubscribe_event           { $$ = $3;                                        }
104                        |  RESET SP CHANNEL SP sampler_channel        { $$ = LSCPSERVER->ResetChannel($5);              }                        |  RESET SP CHANNEL SP sampler_channel        { $$ = LSCPSERVER->ResetChannel($5);              }
105                        |  QUIT                                       { LSCPSERVER->AnswerClient("Bye!\r\n"); return 0; }                        |  QUIT                                       { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }
106                        ;                        ;
107    
108  get_instruction       :  AVAILABLE_ENGINES                                              { $$ = LSCPSERVER->GetAvailableEngines(); }  subscribe_event       :  CHANNELS                                   { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channels); }
109                        |  CHANNELS                                                       { $$ = LSCPSERVER->GetChannels();         }                        |  VOICE_COUNT                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); }
110                        |  CHANNEL SP INFO SP sampler_channel                             { $$ = LSCPSERVER->GetChannelInfo($5);    }                        |  STREAM_COUNT                               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); }
111                        |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel  { $$ = LSCPSERVER->GetBufferFill($5, $7); }                        |  BUFFER_FILL                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); }
112                        |  CHANNEL SP STREAM_COUNT SP sampler_channel                     { $$ = LSCPSERVER->GetStreamCount($5);    }                        |  INFO                                       { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_info); }
113                        |  CHANNEL SP VOICE_COUNT SP sampler_channel                      { $$ = LSCPSERVER->GetVoiceCount($5);     }                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); }
114                        |  ENGINE SP INFO SP engine_name                                  { $$ = LSCPSERVER->GetEngineInfo($5);     }                        ;
115    
116    unsubscribe_event     :  CHANNELS                                   { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channels); }
117                          |  VOICE_COUNT                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); }
118                          |  STREAM_COUNT                               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); }
119                          |  BUFFER_FILL                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); }
120                          |  INFO                                       { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_info); }
121                          |  MISCELLANEOUS                              { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); }
122                          ;
123    
124    get_instruction       :  AVAILABLE_ENGINES                          { $$ = LSCPSERVER->GetAvailableEngines();       }
125                          |  AVAILABLE_MIDI_INPUT_DRIVERS               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();       }
126                          |  MIDI_INPUT_DRIVER SP INFO SP string        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);       }
127                          |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string     { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7);       }
128                          |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list    { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7, $9);       }
129                          |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                                             { $$ = LSCPSERVER->GetAvailableAudioOutputDrivers();       }
130                          |  AUDIO_OUTPUT_DRIVER SP INFO SP string                                      { $$ = LSCPSERVER->GetAudioOutputDriverInfo($5);       }
131                          |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string                  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7);       }
132                          |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7, $9);       }
133                          |  AUDIO_OUTPUT_DEVICES                                                       { $$ = LSCPSERVER->GetAudioOutputDeviceCount();       }
134                          |  MIDI_INPUT_DEVICES                                                         { $$ = LSCPSERVER->GetMidiInputDeviceCount();       }
135                          |  AUDIO_OUTPUT_DEVICE SP INFO SP NUMBER                                      { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5);       }
136                          |  MIDI_INPUT_DEVICE SP INFO SP NUMBER                                        { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5);       }
137                          |  MIDI_INPUT_PORT SP INFO SP NUMBER SP NUMBER                                { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7);       }
138                          |  MIDI_INPUT_PORT_PARAMETER SP INFO SP NUMBER SP NUMBER SP string            { $$ = LSCPSERVER->GetMidiInputPortParameterInfo($5, $7, $9);       }
139                          |  AUDIO_OUTPUT_CHANNEL SP INFO SP NUMBER SP NUMBER                           { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7);       }
140                          |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP NUMBER SP NUMBER SP string       { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9);       }
141                          |  CHANNELS                                                                   { $$ = LSCPSERVER->GetChannels();       }
142                          |  CHANNEL SP INFO SP sampler_channel                                         { $$ = LSCPSERVER->GetChannelInfo($5);       }
143                          |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel              { $$ = LSCPSERVER->GetBufferFill($5, $7);       }
144                          |  CHANNEL SP STREAM_COUNT SP sampler_channel                                 { $$ = LSCPSERVER->GetStreamCount($5);       }
145                          |  CHANNEL SP VOICE_COUNT SP sampler_channel                                  { $$ = LSCPSERVER->GetVoiceCount($5);       }
146                          |  ENGINE SP INFO SP engine_name                                              { $$ = LSCPSERVER->GetEngineInfo($5);       }
147                          ;
148    
149    set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);       }
150                          |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9);       }
151                          |  MIDI_INPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);       }
152                          |  MIDI_INPUT_PORT_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);       }
153                          |  CHANNEL SP set_chan_instruction                                            { $$ = $3;                                                         }
154                          ;
155    
156    create_instruction    :  AUDIO_OUTPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }
157                          |  AUDIO_OUTPUT_DEVICE SP string                 { $$ = LSCPSERVER->CreateAudioOutputDevice($3);    }
158                          |  MIDI_INPUT_DEVICE SP string SP key_val_list   { $$ = LSCPSERVER->CreateMidiInputDevice($3,$5);   }
159                          |  MIDI_INPUT_DEVICE SP string                   { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }
160                          ;
161    
162    destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP NUMBER  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3);       }
163                          |  MIDI_INPUT_DEVICE SP NUMBER    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);         }
164                        ;                        ;
165    
166  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }
167                        |  ENGINE SP load_engine_args     { $$ = $3; }                        |  ENGINE SP load_engine_args     { $$ = $3; }
168                        ;                        ;
169    
170  set_chan_instruction  :  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_output_channel  { $$ = LSCPSERVER->SetAudioOutputChannel($5, $3); }  set_chan_instruction  :  AUDIO_OUTPUT_DEVICE SP sampler_channel SP audio_output_device                            { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3);      }
171                        |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type        { $$ = LSCPSERVER->SetAudioOutputType($5, $3);    }                        |  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_output_channel SP audio_output_channel  { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }
172                        |  MIDI_INPUT_PORT SP sampler_channel SP midi_input_port            { $$ = LSCPSERVER->SetMIDIInputPort($5, $3);      }                        |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type                                { $$ = LSCPSERVER->SetAudioOutputType($5, $3);        }
173                        |  MIDI_INPUT_CHANNEL SP sampler_channel SP midi_input_channel      { $$ = LSCPSERVER->SetMIDIInputChannel($5, $3);   }                        |  MIDI_INPUT SP sampler_channel SP midi_input_device SP midi_input_port SP midi_input_channel  { $$ = LSCPSERVER->SetMIDIInput($5, $7, $9, $3);  }
174                        |  MIDI_INPUT_TYPE SP sampler_channel SP midi_input_type            { $$ = LSCPSERVER->SetMIDIInputType($5, $3);      }                        |  MIDI_INPUT_DEVICE SP sampler_channel SP midi_input_device                                { $$ = LSCPSERVER->SetMIDIInputDevice($5, $3);        }
175                        |  VOLUME SP sampler_channel SP volume                              { $$ = LSCPSERVER->SetVolume($5, $3);             }                        |  MIDI_INPUT_PORT SP sampler_channel SP midi_input_port                                    { $$ = LSCPSERVER->SetMIDIInputPort($5, $3);          }
176                          |  MIDI_INPUT_CHANNEL SP sampler_channel SP midi_input_channel                              { $$ = LSCPSERVER->SetMIDIInputChannel($5, $3);       }
177                          |  MIDI_INPUT_TYPE SP sampler_channel SP midi_input_type                                    { $$ = LSCPSERVER->SetMIDIInputType($5, $3);          }
178                          |  VOLUME SP sampler_channel SP volume                                                      { $$ = LSCPSERVER->SetVolume($5, $3);                 }
179                          ;
180    
181    key_val_list          :  string EQ param_val                  { $$[$1] = $3;          }
182                          |  key_val_list SP string EQ param_val  { $$ = $1; $$[$3] = $5; }
183                        ;                        ;
184    
185  buffer_size_type      :  BYTES       { $$ = fill_response_bytes;      }  buffer_size_type      :  BYTES       { $$ = fill_response_bytes;      }
186                        |  PERCENTAGE  { $$ = fill_response_percentage; }                        |  PERCENTAGE  { $$ = fill_response_percentage; }
187                        ;                        ;
188    
189  load_instr_args       :  filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); }  list_instruction      :  AUDIO_OUTPUT_DEVICES  { $$ = LSCPSERVER->GetAudioOutputDevices(); }
190                          |  MIDI_INPUT_DEVICES    { $$ = LSCPSERVER->GetMidiInputDevices();   }
191                          |  CHANNELS              { $$ = LSCPSERVER->ListChannels();          }
192                        ;                        ;
193    
194  load_engine_args      :  engine_name SP sampler_channel  { $$ = LSCPSERVER->LoadEngine($1, $3); }  load_instr_args       :  filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($1, $3, $5);       }
195                          |  NON_MODAL SP filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true);       }
196                        ;                        ;
197    
198  audio_output_type     :  ALSA  { $$ = audio_output_type_alsa; }  load_engine_args      :  engine_name SP sampler_channel  { $$ = LSCPSERVER->LoadEngine($1, $3);       }
                       |  JACK  { $$ = audio_output_type_jack; }  
199                        ;                        ;
200    
201  midi_input_type       :  ALSA  { $$ = midi_input_type_alsa; }  audio_output_device   :  NUMBER
202                        ;                        ;
203    
204  volume                :  DOTNUM  audio_output_channel  :  NUMBER
                       |  NUMBER  { $$ = $1; }  
205                        ;                        ;
206    
207  sampler_channel       :  NUMBER  audio_output_type     :  string
208                        ;                        ;
209    
210  instrument_index      :  NUMBER  midi_input_device     :  NUMBER
211                        ;                        ;
212    
213  udp_port              :  NUMBER  midi_input_port       :  NUMBER
214                        ;                        ;
215    
216  audio_output_channel  :  NUMBER  midi_input_channel    :  NUMBER
217                        ;                        ;
218    
219  midi_input_channel    :  NUMBER  midi_input_type       :  string
220                        ;                        ;
221    
222  session_id            :  alpha_num_string  volume                :  DOTNUM
223                          |  NUMBER  { $$ = $1; }
224                        ;                        ;
225    
226  engine_name           :  string  sampler_channel       :  NUMBER
227                        ;                        ;
228    
229  midi_input_port       :  alpha_num_string  instrument_index      :  NUMBER
230                          ;
231    
232    engine_name           :  string
233                        ;                        ;
234    
235  filename              :  alpha_num_string  filename              :  STRINGVAL
                       |  filename SP alpha_num_string  { $$ = $1 + ' ' + $3; }  
236                        ;                        ;
237    
238  alpha_num_string      :  string                   { $$ = $1;                                             }  param_val             :  STRINGVAL                { $$ = $1;                                             }
239                        |  NUMBER                   { std::stringstream ss; ss << $1; $$ = ss.str();       }                        |  NUMBER                   { std::stringstream ss; ss << $1; $$ = ss.str();       }
240                        |  alpha_num_string string  { $$ = $1 + $2;                                        }                        |  DOTNUM                   { std::stringstream ss; ss << $1; $$ = ss.str();       }
                       |  alpha_num_string NUMBER  { std::stringstream ss; ss << $1 << $2; $$ = ss.str(); }  
241                        ;                        ;
242    
243  string                :  CHAR          { std::string s; s = $1; $$ = s; }  string                :  CHAR          { std::string s; s = $1; $$ = s; }
# Line 190  void yyerror(const char* s) { Line 259  void yyerror(const char* s) {
259  void restart(yyparse_param_t* pparam, int& yychar) {  void restart(yyparse_param_t* pparam, int& yychar) {
260      // restart scanner      // restart scanner
261      yyrestart(stdin, pparam->pScanner);      yyrestart(stdin, pparam->pScanner);
     // flush input buffer  
     static char buf[1024];  
     while(recv(hSession, buf, 1024, MSG_DONTWAIT) > 0);  
262      // reset lookahead symbol      // reset lookahead symbol
263      yyclearin;      yyclearin;
264  }  }

Legend:
Removed from v.53  
changed lines
  Added in v.209

  ViewVC Help
Powered by ViewVC