/[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 159 by capela, Tue Jun 29 21:11:50 2004 UTC revision 170 by senkov, Sat Jul 3 20:08:07 2004 UTC
# 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 75  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                        |  comment                        |  comment  { return LSCP_DONE; }
83                        |  command  { LSCPSERVER->AnswerClient($1); }                        |  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    
# Line 104  command               :  ADD SP CHANNEL Line 102  command               :  ADD SP CHANNEL
102                        |  SUBSCRIBE SP subscribe_event               { $$ = $3;                                        }                        |  SUBSCRIBE SP subscribe_event               { $$ = $3;                                        }
103                        |  UNSUBSCRIBE SP unsubscribe_event           { $$ = $3;                                        }                        |  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  subscribe_event       :  CHANNELS                                   { $$ = LSCPSERVER->SubscribeNotification(event_channels); }  subscribe_event       :  CHANNELS                                   { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channels); }
109                        |  VOICE_COUNT                                { $$ = LSCPSERVER->SubscribeNotification(event_voice_count); }                        |  VOICE_COUNT                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); }
110                        |  STREAM_COUNT                               { $$ = LSCPSERVER->SubscribeNotification(event_stream_count); }                        |  STREAM_COUNT                               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); }
111                        |  BUFFER_FILL                                { $$ = LSCPSERVER->SubscribeNotification(event_channel_buffer_fill); }                        |  BUFFER_FILL                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); }
112                        |  INFO                                       { $$ = LSCPSERVER->SubscribeNotification(event_channel_info); }                        |  INFO                                       { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_info); }
113                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->SubscribeNotification(event_misc); }                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); }
114                        ;                        ;
115    
116  unsubscribe_event     :  CHANNELS                                   { $$ = LSCPSERVER->UnsubscribeNotification(event_channels); }  unsubscribe_event     :  CHANNELS                                   { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channels); }
117                        |  VOICE_COUNT                                { $$ = LSCPSERVER->UnsubscribeNotification(event_voice_count); }                        |  VOICE_COUNT                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); }
118                        |  STREAM_COUNT                               { $$ = LSCPSERVER->UnsubscribeNotification(event_stream_count); }                        |  STREAM_COUNT                               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); }
119                        |  BUFFER_FILL                                { $$ = LSCPSERVER->UnsubscribeNotification(event_channel_buffer_fill); }                        |  BUFFER_FILL                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); }
120                        |  INFO                                       { $$ = LSCPSERVER->UnsubscribeNotification(event_channel_info); }                        |  INFO                                       { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_info); }
121                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->UnsubscribeNotification(event_misc); }                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); }
122                        ;                        ;
123    
124  get_instruction       :  AVAILABLE_ENGINES                                                          { $$ = LSCPSERVER->GetAvailableEngines();                          }  get_instruction       :  AVAILABLE_ENGINES                          { $$ = LSCPSERVER->GetAvailableEngines();       }
125                        |  AVAILABLE_MIDI_INPUT_DRIVERS                                               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();               }                        |  AVAILABLE_MIDI_INPUT_DRIVERS               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();       }
126                        |  MIDI_INPUT_DRIVER SP INFO SP string                                        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);                   }                        |  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);      }                        |  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);  }                        |  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();               }                        |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                                             { $$ = LSCPSERVER->GetAvailableAudioOutputDrivers();       }
130                        |  AUDIO_OUTPUT_DRIVER SP INFO SP string                                      { $$ = LSCPSERVER->GetAudioOutputDriverInfo($5);                   }                        |  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);      }                        |  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);  }                        |  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();                    }                        |  AUDIO_OUTPUT_DEVICES                                                       { $$ = LSCPSERVER->GetAudioOutputDeviceCount();       }
134                        |  MIDI_INPUT_DEVICES                                                         { $$ = LSCPSERVER->GetMidiInputDeviceCount();                    }                        |  MIDI_INPUT_DEVICES                                                         { $$ = LSCPSERVER->GetMidiInputDeviceCount();       }
135                        |  AUDIO_OUTPUT_DEVICE SP INFO SP NUMBER                                      { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5);                   }                        |  AUDIO_OUTPUT_DEVICE SP INFO SP NUMBER                                      { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5);       }
136                        |  MIDI_INPUT_DEVICE SP INFO SP NUMBER                                        { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5);                   }                        |  MIDI_INPUT_DEVICE SP INFO SP NUMBER                                        { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5);       }
137                        |  MIDI_INPUT_PORT SP INFO SP NUMBER SP NUMBER                                { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7);                   }                        |  MIDI_INPUT_PORT SP INFO SP NUMBER SP NUMBER                                { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7);       }
138                        |  AUDIO_OUTPUT_CHANNEL SP INFO SP NUMBER SP NUMBER                           { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7);              }                        |  AUDIO_OUTPUT_CHANNEL SP INFO SP NUMBER SP NUMBER                           { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7);       }
139                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP NUMBER SP NUMBER SP string       { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9); }                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP NUMBER SP NUMBER SP string       { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9);       }
140                        |  CHANNELS                                                                   { $$ = LSCPSERVER->GetChannels();                                  }                        |  CHANNELS                                                                   { $$ = LSCPSERVER->GetChannels();       }
141                        |  CHANNEL SP INFO SP sampler_channel                                         { $$ = LSCPSERVER->GetChannelInfo($5);                             }                        |  CHANNEL SP INFO SP sampler_channel                                         { $$ = LSCPSERVER->GetChannelInfo($5);       }
142                        |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel              { $$ = LSCPSERVER->GetBufferFill($5, $7);                          }                        |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel              { $$ = LSCPSERVER->GetBufferFill($5, $7);       }
143                        |  CHANNEL SP STREAM_COUNT SP sampler_channel                                 { $$ = LSCPSERVER->GetStreamCount($5);                             }                        |  CHANNEL SP STREAM_COUNT SP sampler_channel                                 { $$ = LSCPSERVER->GetStreamCount($5);       }
144                        |  CHANNEL SP VOICE_COUNT SP sampler_channel                                  { $$ = LSCPSERVER->GetVoiceCount($5);                              }                        |  CHANNEL SP VOICE_COUNT SP sampler_channel                                  { $$ = LSCPSERVER->GetVoiceCount($5);       }
145                        |  ENGINE SP INFO SP engine_name                                              { $$ = LSCPSERVER->GetEngineInfo($5);                              }                        |  ENGINE SP INFO SP engine_name                                              { $$ = LSCPSERVER->GetEngineInfo($5);       }
146                        ;                        ;
147    
148  set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);      }  set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);       }
149                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); }                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9);       }
150                        |  MIDI_INPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7); }                        |  MIDI_INPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);       }
151                        |  MIDI_INPUT_PORT_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9); }                        |  MIDI_INPUT_PORT_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);       }
152                        |  CHANNEL SP set_chan_instruction                                            { $$ = $3;                                                         }                        |  CHANNEL SP set_chan_instruction                                            { $$ = $3;                                                         }
153                        ;                        ;
154    
# Line 160  create_instruction    :  AUDIO_OUTPUT_DE Line 158  create_instruction    :  AUDIO_OUTPUT_DE
158                        |  MIDI_INPUT_DEVICE SP string                   { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }                        |  MIDI_INPUT_DEVICE SP string                   { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }
159                        ;                        ;
160    
161  destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP NUMBER  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); }  destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP NUMBER  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3);       }
162                        |  MIDI_INPUT_DEVICE SP NUMBER    { $$ = LSCPSERVER->DestroyMidiInputDevice($3); }                        |  MIDI_INPUT_DEVICE SP NUMBER    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);         }
163                        ;                        ;
164    
165  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }
# Line 187  buffer_size_type      :  BYTES       { $ Line 185  buffer_size_type      :  BYTES       { $
185                        |  PERCENTAGE  { $$ = fill_response_percentage; }                        |  PERCENTAGE  { $$ = fill_response_percentage; }
186                        ;                        ;
187    
188  list_instruction      :  AUDIO_OUTPUT_DEVICES  { $$ = LSCPSERVER->GetAudioOutputDevices(); }  list_instruction      :  AUDIO_OUTPUT_DEVICES  { $$ = LSCPSERVER->GetAudioOutputDevices();       }
189                        |  MIDI_INPUT_DEVICES    { $$ = LSCPSERVER->GetMidiInputDevices(); }                        |  MIDI_INPUT_DEVICES    { $$ = LSCPSERVER->GetMidiInputDevices();       }
190                        ;                        ;
191    
192  load_instr_args       :  filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); }  load_instr_args       :  filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($1, $3, $5);       }
193                        |  NON_MODAL SP filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true); }                        |  NON_MODAL SP filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true);       }
194                        ;                        ;
195    
196  load_engine_args      :  engine_name SP sampler_channel  { $$ = LSCPSERVER->LoadEngine($1, $3); }  load_engine_args      :  engine_name SP sampler_channel  { $$ = LSCPSERVER->LoadEngine($1, $3);       }
197                        ;                        ;
198    
199  audio_output_device   :  NUMBER  audio_output_device   :  NUMBER
# Line 259  void yyerror(const char* s) { Line 257  void yyerror(const char* s) {
257  void restart(yyparse_param_t* pparam, int& yychar) {  void restart(yyparse_param_t* pparam, int& yychar) {
258      // restart scanner      // restart scanner
259      yyrestart(stdin, pparam->pScanner);      yyrestart(stdin, pparam->pScanner);
     // flush input buffer  
     static char buf[1024];  
     while(recv(hSession, buf, 1024, MSG_DONTWAIT) > 0);  
260      // reset lookahead symbol      // reset lookahead symbol
261      yyclearin;      yyclearin;
262  }  }

Legend:
Removed from v.159  
changed lines
  Added in v.170

  ViewVC Help
Powered by ViewVC