/[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 1695 by schoenebeck, Sat Feb 16 01:09:33 2008 UTC revision 2515 by schoenebeck, Wed Feb 5 20:45:18 2014 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2014 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 34  Line 34 
34  #include "lscpparser.h"  #include "lscpparser.h"
35  #include "lscpserver.h"  #include "lscpserver.h"
36  #include "lscpevent.h"  #include "lscpevent.h"
37    #include "lscpsymbols.h"
38    #include <algorithm>
39    #include "lscp.h"
40    
41    namespace LinuxSampler {
42    
43  // to save us typing work in the rules action definitions  // to save us typing work in the rules action definitions
44  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer
45  #define SESSION_PARAM ((yyparse_param_t*) yyparse_param)  #define SESSION_PARAM ((yyparse_param_t*) yyparse_param)
46  #define INCREMENT_LINE { SESSION_PARAM->iLine++; SESSION_PARAM->iColumn = 0; }  #define INCREMENT_LINE { SESSION_PARAM->iLine++; SESSION_PARAM->iColumn = 0; sParsed.clear(); }
47    
48  // clears input buffer  // clears input buffer
49  void restart(yyparse_param_t* pparam, int& yychar);  void restart(yyparse_param_t* pparam, int& yychar);
50  #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar)  #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar)
51    
 // we provide our own version of yyerror() so we don't have to link against the yacc library  
 void yyerror(const char* s);  
   
52  static char buf[1024]; // input buffer to feed the parser with new characters  static char buf[1024]; // input buffer to feed the parser with new characters
53  static int bytes = 0;  // current number of characters in the input buffer  static int bytes = 0;  // current number of characters in the input buffer
54  static int ptr   = 0;  // current position in the input buffer  static int ptr   = 0;  // current position in the input buffer
55  static String sLastError; // error message of the last error occured  static String sLastError; // error message of the last error occured
56    static String sParsed; ///< Characters of current line which have already been shifted (consumed/parsed) by the parser.
57    
58  // external reference to the function which actually reads from the socket  // external reference to the function which actually reads from the socket
59  extern int GetLSCPCommand( void *buf, int max_size);  extern int GetLSCPCommand( void *buf, int max_size);
# Line 81  int yylex(YYSTYPE* yylval) { Line 84  int yylex(YYSTYPE* yylval) {
84      const char c = buf[ptr++];      const char c = buf[ptr++];
85      // increment current reading position (just for verbosity / messages)      // increment current reading position (just for verbosity / messages)
86      GetCurrentYaccSession()->iColumn++;      GetCurrentYaccSession()->iColumn++;
87        sParsed += c;
88      // we have to handle "normal" and "extended" ASCII characters separately      // we have to handle "normal" and "extended" ASCII characters separately
89      if (isExtendedAsciiChar(c)) {      if (isExtendedAsciiChar(c)) {
90          // workaround for characters with ASCII code higher than 127          // workaround for characters with ASCII code higher than 127
# Line 101  int octalsToNumber(char oct_digit0, char Line 105  int octalsToNumber(char oct_digit0, char
105      return atoi(d2)*8*8 + atoi(d1)*8 + atoi(d0);      return atoi(d2)*8*8 + atoi(d1)*8 + atoi(d0);
106  }  }
107    
108    }
109    
110    using namespace LinuxSampler;
111    
112    static std::set<String> yyExpectedSymbols();
113    
114    /**
115     * Will be called when an error occured (usually syntax error).
116     *
117     * We provide our own version of yyerror() so we a) don't have to link against
118     * the yacc library and b) can render more helpful syntax error messages.
119     */
120    void yyerror(void* x, const char* s) {
121        yyparse_param_t* param = GetCurrentYaccSession();
122    
123        // get the text part already parsed (of current line)
124        const bool bContainsLineFeed =
125            sParsed.find('\r') != std::string::npos ||
126            sParsed.find('\n') != std::string::npos;
127        // remove potential line feed characters
128        if (bContainsLineFeed) {
129            for (size_t p = sParsed.find('\r'); p != std::string::npos;
130                 p = sParsed.find('\r')) sParsed.erase(p);
131            for (size_t p = sParsed.find('\n'); p != std::string::npos;
132                 p = sParsed.find('\n')) sParsed.erase(p);
133        }
134    
135        // start assembling the error message with Bison's own message
136        String txt = s;
137    
138        // append exact position info of syntax error
139        txt += (" (line:"  + ToString(param->iLine+1)) +
140               (",column:" + ToString(param->iColumn)) + ")";
141    
142        // append the part of the lined that has already been parsed
143        txt += ". Context: \"" + sParsed;
144        if (txt.empty() || bContainsLineFeed)
145            txt += "^";
146        else
147            txt.insert(txt.size() - 1, "^");
148        txt += "...\"";
149    
150        // append the non-terminal symbols expected now/next
151        std::set<String> expectedSymbols = yyExpectedSymbols();
152        for (std::set<String>::const_iterator it = expectedSymbols.begin();
153             it != expectedSymbols.end(); ++it)
154        {
155            if (it == expectedSymbols.begin())
156                txt += " -> Should be: " + *it;
157            else
158                txt += " | " + *it;
159        }
160    
161        dmsg(2,("LSCPParser: %s\n", txt.c_str()));
162        sLastError = txt;
163    }
164    
165  %}  %}
166    
167  // reentrant parser  // reentrant parser
168  %pure_parser  %pure-parser
169    
170    %parse-param {void* yyparse_param}
171    
172    // After entering the yyparse() function, store references to the parser's
173    // state stack, so that we can create more helpful syntax error messages than
174    // Bison (2.x) could do.
175    %initial-action {
176        yyparse_param_t* p = (yyparse_param_t*) yyparse_param;
177        p->ppStackBottom = &yyss;
178        p->ppStackTop    = &yyssp;
179    }
180    
181  // tell bison to spit out verbose syntax error messages  // tell bison to spit out verbose syntax error messages
182  %error-verbose  %error-verbose
# Line 112  int octalsToNumber(char oct_digit0, char Line 184  int octalsToNumber(char oct_digit0, char
184  %token <Char> EXT_ASCII_CHAR  %token <Char> EXT_ASCII_CHAR
185    
186  %type <Char> char char_base alpha_char digit digit_oct digit_hex escape_seq escape_seq_octal escape_seq_hex  %type <Char> char char_base alpha_char digit digit_oct digit_hex escape_seq escape_seq_octal escape_seq_hex
187  %type <Dotnum> dotnum volume_value boolean  %type <Dotnum> real dotnum volume_value boolean control_value
188  %type <Number> number sampler_channel instrument_index fx_send_id audio_channel_index device_index midi_input_channel_index midi_input_port_index midi_map midi_bank midi_prog midi_ctrl  %type <Number> number sampler_channel instrument_index fx_send_id audio_channel_index device_index effect_index effect_instance effect_chain chain_pos input_control midi_input_channel_index midi_input_port_index midi_map midi_bank midi_prog midi_ctrl
189  %type <String> string string_escaped text text_escaped text_escaped_base stringval stringval_escaped digits param_val_list param_val query_val filename db_path map_name entry_name fx_send_name engine_name command add_instruction create_instruction destroy_instruction get_instruction list_instruction load_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type_name midi_input_type_name remove_instruction unmap_instruction set_instruction subscribe_event unsubscribe_event map_instruction reset_instruction clear_instruction find_instruction move_instruction copy_instruction scan_mode edit_instruction format_instruction  %type <String> string string_escaped text text_escaped text_escaped_base stringval stringval_escaped digits param_val_list param_val query_val filename module effect_system db_path map_name entry_name fx_send_name effect_name engine_name command add_instruction create_instruction destroy_instruction get_instruction list_instruction load_instruction send_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type_name midi_input_type_name remove_instruction unmap_instruction set_instruction subscribe_event unsubscribe_event map_instruction reset_instruction clear_instruction find_instruction move_instruction copy_instruction scan_mode edit_instruction format_instruction append_instruction insert_instruction
190  %type <FillResponse> buffer_size_type  %type <FillResponse> buffer_size_type
191  %type <KeyValList> key_val_list query_val_list  %type <KeyValList> key_val_list query_val_list
192  %type <LoadMode> instr_load_mode  %type <LoadMode> instr_load_mode
# Line 172  command               :  ADD SP add_inst Line 244  command               :  ADD SP add_inst
244                        |  COPY SP copy_instruction              { $$ = $3;                                                }                        |  COPY SP copy_instruction              { $$ = $3;                                                }
245                        |  EDIT SP edit_instruction              { $$ = $3;                                                }                        |  EDIT SP edit_instruction              { $$ = $3;                                                }
246                        |  FORMAT SP format_instruction          { $$ = $3;                                                }                        |  FORMAT SP format_instruction          { $$ = $3;                                                }
247                          |  SEND SP send_instruction              { $$ = $3;                                                }
248                          |  APPEND SP append_instruction          { $$ = $3;                                                }
249                          |  INSERT SP insert_instruction          { $$ = $3;                                                }
250                        |  RESET                                 { $$ = LSCPSERVER->ResetSampler();                        }                        |  RESET                                 { $$ = LSCPSERVER->ResetSampler();                        }
251                        |  QUIT                                  { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }                        |  QUIT                                  { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }
252                        ;                        ;
253    
254  add_instruction       :  CHANNEL                               { $$ = LSCPSERVER->AddChannel();                  }  add_instruction       :  CHANNEL                               { $$ = LSCPSERVER->AddChannel();                  }
255                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index                           { $$ = LSCPSERVER->AddChannelMidiInput($5,$7);    }
256                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index SP midi_input_port_index  { $$ = LSCPSERVER->AddChannelMidiInput($5,$7,$9); }
257                        |  DB_INSTRUMENT_DIRECTORY SP db_path    { $$ = LSCPSERVER->AddDbInstrumentDirectory($3);  }                        |  DB_INSTRUMENT_DIRECTORY SP db_path    { $$ = LSCPSERVER->AddDbInstrumentDirectory($3);  }
258                        |  DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP db_path SP filename         { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);  }                        |  DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP db_path SP filename                        { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);        }
259                        |  DB_INSTRUMENTS SP scan_mode SP db_path SP filename                      { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);        }                        |  DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP FILE_AS_DIR SP db_path SP filename         { $$ = LSCPSERVER->AddDbInstruments($5,$9,$11, true, true); }
260                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename                      { $$ = LSCPSERVER->AddDbInstruments($5,$7, -1, true); }                        |  DB_INSTRUMENTS SP scan_mode SP db_path SP filename                                     { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);              }
261                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename SP instrument_index  { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);  }                        |  DB_INSTRUMENTS SP scan_mode SP FILE_AS_DIR SP db_path SP filename                      { $$ = LSCPSERVER->AddDbInstruments($3,$7,$9, false, true); }
262                        |  DB_INSTRUMENTS SP db_path SP filename                                   { $$ = LSCPSERVER->AddDbInstruments($3,$5);           }                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename                                     { $$ = LSCPSERVER->AddDbInstruments($5,$7, -1, true);       }
263                        |  DB_INSTRUMENTS SP db_path SP filename SP instrument_index               { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);        }                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename SP instrument_index                 { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);        }
264                          |  DB_INSTRUMENTS SP db_path SP filename                                                  { $$ = LSCPSERVER->AddDbInstruments($3,$5);                 }
265                          |  DB_INSTRUMENTS SP db_path SP filename SP instrument_index                              { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);              }
266                        |  MIDI_INSTRUMENT_MAP                   { $$ = LSCPSERVER->AddMidiInstrumentMap();                }                        |  MIDI_INSTRUMENT_MAP                   { $$ = LSCPSERVER->AddMidiInstrumentMap();                }
267                        |  MIDI_INSTRUMENT_MAP SP map_name       { $$ = LSCPSERVER->AddMidiInstrumentMap($3);              }                        |  MIDI_INSTRUMENT_MAP SP map_name       { $$ = LSCPSERVER->AddMidiInstrumentMap($3);              }
268                          |  SEND_EFFECT_CHAIN SP device_index     { $$ = LSCPSERVER->AddSendEffectChain($3);                }
269                        ;                        ;
270    
271  subscribe_event       :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_audio_device_count);   }  subscribe_event       :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_audio_device_count);   }
# Line 214  subscribe_event       :  AUDIO_OUTPUT_DE Line 294  subscribe_event       :  AUDIO_OUTPUT_DE
294                        |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_stream_count);   }                        |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_stream_count);   }
295                        |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_voice_count);    }                        |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_voice_count);    }
296                        |  GLOBAL_INFO                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_global_info);          }                        |  GLOBAL_INFO                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_global_info);          }
297                          |  EFFECT_INSTANCE_COUNT                 { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_instance_count);    }
298                          |  EFFECT_INSTANCE_INFO                  { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_instance_info);     }
299                          |  SEND_EFFECT_CHAIN_COUNT               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_send_fx_chain_count);  }
300                          |  SEND_EFFECT_CHAIN_INFO                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_send_fx_chain_info);   }
301                        ;                        ;
302    
303  unsubscribe_event     :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_audio_device_count);   }  unsubscribe_event     :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_audio_device_count);   }
# Line 242  unsubscribe_event     :  AUDIO_OUTPUT_DE Line 326  unsubscribe_event     :  AUDIO_OUTPUT_DE
326                        |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_stream_count);   }                        |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_stream_count);   }
327                        |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_voice_count);    }                        |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_voice_count);    }
328                        |  GLOBAL_INFO                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_global_info);          }                        |  GLOBAL_INFO                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_global_info);          }
329                          |  EFFECT_INSTANCE_COUNT                 { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_instance_count);    }
330                          |  EFFECT_INSTANCE_INFO                  { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_instance_info);     }
331                          |  SEND_EFFECT_CHAIN_COUNT               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_send_fx_chain_count);  }
332                          |  SEND_EFFECT_CHAIN_INFO                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_send_fx_chain_info);   }
333                        ;                        ;
334    
335  map_instruction       :  MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,MidiInstrumentMapper::DONTCARE,"",$3); }  map_instruction       :  MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,MidiInstrumentMapper::DONTCARE,"",$3); }
# Line 254  unmap_instruction     :  MIDI_INSTRUMENT Line 342  unmap_instruction     :  MIDI_INSTRUMENT
342                        ;                        ;
343    
344  remove_instruction    :  CHANNEL SP sampler_channel                   { $$ = LSCPSERVER->RemoveChannel($3);                      }  remove_instruction    :  CHANNEL SP sampler_channel                   { $$ = LSCPSERVER->RemoveChannel($3);                      }
345                          |  CHANNEL SP MIDI_INPUT SP sampler_channel                                           { $$ = LSCPSERVER->RemoveChannelMidiInput($5);       }
346                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index                           { $$ = LSCPSERVER->RemoveChannelMidiInput($5,$7);    }
347                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index SP midi_input_port_index  { $$ = LSCPSERVER->RemoveChannelMidiInput($5,$7,$9); }
348                        |  MIDI_INSTRUMENT_MAP SP midi_map              { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3);            }                        |  MIDI_INSTRUMENT_MAP SP midi_map              { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3);            }
349                        |  MIDI_INSTRUMENT_MAP SP ALL                   { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps();          }                        |  MIDI_INSTRUMENT_MAP SP ALL                   { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps();          }
350                          |  SEND_EFFECT_CHAIN SP device_index SP effect_chain  { $$ = LSCPSERVER->RemoveSendEffectChain($3,$5);     }
351                          |  SEND_EFFECT_CHAIN SP EFFECT SP device_index SP effect_chain SP chain_pos  { $$ = LSCPSERVER->RemoveSendEffectChainEffect($5,$7,$9); }
352                          |  FX_SEND SP EFFECT SP sampler_channel SP fx_send_id  { $$ = LSCPSERVER->SetFxSendEffect($5,$7,-1,-1);    }
353                        |  DB_INSTRUMENT_DIRECTORY SP FORCE SP db_path  { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($5, true);  }                        |  DB_INSTRUMENT_DIRECTORY SP FORCE SP db_path  { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($5, true);  }
354                        |  DB_INSTRUMENT_DIRECTORY SP db_path           { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($3);        }                        |  DB_INSTRUMENT_DIRECTORY SP db_path           { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($3);        }
355                        |  DB_INSTRUMENT SP db_path                     { $$ = LSCPSERVER->RemoveDbInstrument($3);                 }                        |  DB_INSTRUMENT SP db_path                     { $$ = LSCPSERVER->RemoveDbInstrument($3);                 }
356                        ;                        ;
357    
358  get_instruction       :  AVAILABLE_ENGINES                                                          { $$ = LSCPSERVER->GetAvailableEngines();                          }  get_instruction       :  AVAILABLE_ENGINES                                                          { $$ = LSCPSERVER->GetAvailableEngines();                          }
359                          |  AVAILABLE_EFFECTS                                                          { $$ = LSCPSERVER->GetAvailableEffects();                          }
360                          |  EFFECT_INSTANCES                                                           { $$ = LSCPSERVER->GetEffectInstances();                           }
361                          |  EFFECT SP INFO SP effect_index                                             { $$ = LSCPSERVER->GetEffectInfo($5);                              }
362                          |  EFFECT_INSTANCE SP INFO SP effect_instance                                 { $$ = LSCPSERVER->GetEffectInstanceInfo($5);                      }
363                          |  EFFECT_INSTANCE_INPUT_CONTROL SP INFO SP effect_instance SP input_control  { $$ = LSCPSERVER->GetEffectInstanceInputControlInfo($5,$7);       }
364                          |  SEND_EFFECT_CHAINS SP device_index                                         { $$ = LSCPSERVER->GetSendEffectChains($3);                        }
365                          |  SEND_EFFECT_CHAIN SP INFO SP device_index SP effect_chain                  { $$ = LSCPSERVER->GetSendEffectChainInfo($5,$7);                  }
366                        |  AVAILABLE_MIDI_INPUT_DRIVERS                                               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();                 }                        |  AVAILABLE_MIDI_INPUT_DRIVERS                                               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();                 }
367                        |  MIDI_INPUT_DRIVER SP INFO SP string                                        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);                     }                        |  MIDI_INPUT_DRIVER SP INFO SP string                                        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);                     }
368                        |  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);        }
# Line 303  get_instruction       :  AVAILABLE_ENGIN Line 404  get_instruction       :  AVAILABLE_ENGIN
404                        |  DB_INSTRUMENT SP INFO SP db_path                                           { $$ = LSCPSERVER->GetDbInstrumentInfo($5);                        }                        |  DB_INSTRUMENT SP INFO SP db_path                                           { $$ = LSCPSERVER->GetDbInstrumentInfo($5);                        }
405                        |  DB_INSTRUMENTS_JOB SP INFO SP number                                       { $$ = LSCPSERVER->GetDbInstrumentsJobInfo($5);                    }                        |  DB_INSTRUMENTS_JOB SP INFO SP number                                       { $$ = LSCPSERVER->GetDbInstrumentsJobInfo($5);                    }
406                        |  VOLUME                                                                     { $$ = LSCPSERVER->GetGlobalVolume();                              }                        |  VOLUME                                                                     { $$ = LSCPSERVER->GetGlobalVolume();                              }
407                          |  VOICES                                                                     { $$ = LSCPSERVER->GetGlobalMaxVoices();                           }
408                          |  STREAMS                                                                    { $$ = LSCPSERVER->GetGlobalMaxStreams();                          }
409                        |  FILE SP INSTRUMENTS SP filename                                            { $$ = LSCPSERVER->GetFileInstruments($5);                         }                        |  FILE SP INSTRUMENTS SP filename                                            { $$ = LSCPSERVER->GetFileInstruments($5);                         }
410                        |  FILE SP INSTRUMENT SP INFO SP filename SP instrument_index                 { $$ = LSCPSERVER->GetFileInstrumentInfo($7,$9);                   }                        |  FILE SP INSTRUMENT SP INFO SP filename SP instrument_index                 { $$ = LSCPSERVER->GetFileInstrumentInfo($7,$9);                   }
411                        ;                        ;
# Line 312  set_instruction       :  AUDIO_OUTPUT_DE Line 415  set_instruction       :  AUDIO_OUTPUT_DE
415                        |  MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);        }                        |  MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);        }
416                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' NONE                 { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, "");      }                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' NONE                 { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, "");      }
417                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);      }                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);      }
418                          |  EFFECT_INSTANCE_INPUT_CONTROL SP VALUE SP effect_instance SP input_control SP control_value  { $$ = LSCPSERVER->SetEffectInstanceInputControlValue($5, $7, $9); }
419                        |  CHANNEL SP set_chan_instruction                                                  { $$ = $3;                                                         }                        |  CHANNEL SP set_chan_instruction                                                  { $$ = $3;                                                         }
420                        |  MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name                              { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7);               }                        |  MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name                              { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7);               }
421                        |  FX_SEND SP NAME SP sampler_channel SP fx_send_id SP fx_send_name                 { $$ = LSCPSERVER->SetFxSendName($5,$7,$9);                        }                        |  FX_SEND SP NAME SP sampler_channel SP fx_send_id SP fx_send_name                 { $$ = LSCPSERVER->SetFxSendName($5,$7,$9);                        }
422                        |  FX_SEND SP AUDIO_OUTPUT_CHANNEL SP sampler_channel SP fx_send_id SP audio_channel_index SP audio_channel_index  { $$ = LSCPSERVER->SetFxSendAudioOutputChannel($5,$7,$9,$11); }                        |  FX_SEND SP AUDIO_OUTPUT_CHANNEL SP sampler_channel SP fx_send_id SP audio_channel_index SP audio_channel_index  { $$ = LSCPSERVER->SetFxSendAudioOutputChannel($5,$7,$9,$11); }
423                        |  FX_SEND SP MIDI_CONTROLLER SP sampler_channel SP fx_send_id SP midi_ctrl         { $$ = LSCPSERVER->SetFxSendMidiController($5,$7,$9);              }                        |  FX_SEND SP MIDI_CONTROLLER SP sampler_channel SP fx_send_id SP midi_ctrl         { $$ = LSCPSERVER->SetFxSendMidiController($5,$7,$9);              }
424                        |  FX_SEND SP LEVEL SP sampler_channel SP fx_send_id SP volume_value                { $$ = LSCPSERVER->SetFxSendLevel($5,$7,$9);                       }                        |  FX_SEND SP LEVEL SP sampler_channel SP fx_send_id SP volume_value                { $$ = LSCPSERVER->SetFxSendLevel($5,$7,$9);                       }
425                          |  FX_SEND SP EFFECT SP sampler_channel SP fx_send_id SP effect_chain SP chain_pos  { $$ = LSCPSERVER->SetFxSendEffect($5,$7,$9,$11);                  }
426                        |  DB_INSTRUMENT_DIRECTORY SP NAME SP db_path SP stringval_escaped                  { $$ = LSCPSERVER->SetDbInstrumentDirectoryName($5,$7);            }                        |  DB_INSTRUMENT_DIRECTORY SP NAME SP db_path SP stringval_escaped                  { $$ = LSCPSERVER->SetDbInstrumentDirectoryName($5,$7);            }
427                        |  DB_INSTRUMENT_DIRECTORY SP DESCRIPTION SP db_path SP stringval_escaped           { $$ = LSCPSERVER->SetDbInstrumentDirectoryDescription($5,$7);     }                        |  DB_INSTRUMENT_DIRECTORY SP DESCRIPTION SP db_path SP stringval_escaped           { $$ = LSCPSERVER->SetDbInstrumentDirectoryDescription($5,$7);     }
428                        |  DB_INSTRUMENT SP NAME SP db_path SP stringval_escaped                            { $$ = LSCPSERVER->SetDbInstrumentName($5,$7);                     }                        |  DB_INSTRUMENT SP NAME SP db_path SP stringval_escaped                            { $$ = LSCPSERVER->SetDbInstrumentName($5,$7);                     }
429                        |  DB_INSTRUMENT SP DESCRIPTION SP db_path SP stringval_escaped                     { $$ = LSCPSERVER->SetDbInstrumentDescription($5,$7);              }                        |  DB_INSTRUMENT SP DESCRIPTION SP db_path SP stringval_escaped                     { $$ = LSCPSERVER->SetDbInstrumentDescription($5,$7);              }
430                          |  DB_INSTRUMENT SP FILE_PATH SP filename SP filename                               { $$ = LSCPSERVER->SetDbInstrumentFilePath($5,$7);                 }
431                        |  ECHO SP boolean                                                                  { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3);  }                        |  ECHO SP boolean                                                                  { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3);  }
432                          |  SHELL SP INTERACT SP boolean                                                     { $$ = LSCPSERVER->SetShellInteract((yyparse_param_t*) yyparse_param, $5); }
433                        |  VOLUME SP volume_value                                                           { $$ = LSCPSERVER->SetGlobalVolume($3);                            }                        |  VOLUME SP volume_value                                                           { $$ = LSCPSERVER->SetGlobalVolume($3);                            }
434                          |  VOICES SP number                                                                 { $$ = LSCPSERVER->SetGlobalMaxVoices($3);                         }
435                          |  STREAMS SP number                                                                { $$ = LSCPSERVER->SetGlobalMaxStreams($3);                        }
436                        ;                        ;
437    
438  create_instruction    :  AUDIO_OUTPUT_DEVICE SP string SP key_val_list  { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }  create_instruction    :  AUDIO_OUTPUT_DEVICE SP string SP key_val_list  { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }
# Line 332  create_instruction    :  AUDIO_OUTPUT_DE Line 441  create_instruction    :  AUDIO_OUTPUT_DE
441                        |  MIDI_INPUT_DEVICE SP string                    { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }                        |  MIDI_INPUT_DEVICE SP string                    { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }
442                        |  FX_SEND SP sampler_channel SP midi_ctrl        { $$ = LSCPSERVER->CreateFxSend($3,$5);            }                        |  FX_SEND SP sampler_channel SP midi_ctrl        { $$ = LSCPSERVER->CreateFxSend($3,$5);            }
443                        |  FX_SEND SP sampler_channel SP midi_ctrl SP fx_send_name  { $$ = LSCPSERVER->CreateFxSend($3,$5,$7); }                        |  FX_SEND SP sampler_channel SP midi_ctrl SP fx_send_name  { $$ = LSCPSERVER->CreateFxSend($3,$5,$7); }
444                          |  EFFECT_INSTANCE SP effect_index                { $$ = LSCPSERVER->CreateEffectInstance($3);       }
445                          |  EFFECT_INSTANCE SP effect_system SP module SP effect_name  { $$ = LSCPSERVER->CreateEffectInstance($3,$5,$7); }
446                        ;                        ;
447    
448  reset_instruction     :  CHANNEL SP sampler_channel  { $$ = LSCPSERVER->ResetChannel($3); }  reset_instruction     :  CHANNEL SP sampler_channel  { $$ = LSCPSERVER->ResetChannel($3); }
# Line 345  find_instruction      :  DB_INSTRUMENTS Line 456  find_instruction      :  DB_INSTRUMENTS
456                        |  DB_INSTRUMENTS SP db_path SP query_val_list                               { $$ = LSCPSERVER->FindDbInstruments($3,$5, true);            }                        |  DB_INSTRUMENTS SP db_path SP query_val_list                               { $$ = LSCPSERVER->FindDbInstruments($3,$5, true);            }
457                        |  DB_INSTRUMENT_DIRECTORIES SP NON_RECURSIVE SP db_path SP query_val_list   { $$ = LSCPSERVER->FindDbInstrumentDirectories($5,$7, false); }                        |  DB_INSTRUMENT_DIRECTORIES SP NON_RECURSIVE SP db_path SP query_val_list   { $$ = LSCPSERVER->FindDbInstrumentDirectories($5,$7, false); }
458                        |  DB_INSTRUMENT_DIRECTORIES SP db_path SP query_val_list                    { $$ = LSCPSERVER->FindDbInstrumentDirectories($3,$5, true);  }                        |  DB_INSTRUMENT_DIRECTORIES SP db_path SP query_val_list                    { $$ = LSCPSERVER->FindDbInstrumentDirectories($3,$5, true);  }
459                          |  LOST SP DB_INSTRUMENT_FILES                                               { $$ = LSCPSERVER->FindLostDbInstrumentFiles();                 }
460                        ;                        ;
461    
462  move_instruction      :  DB_INSTRUMENT_DIRECTORY SP db_path SP db_path    { $$ = LSCPSERVER->MoveDbInstrumentDirectory($3,$5); }  move_instruction      :  DB_INSTRUMENT_DIRECTORY SP db_path SP db_path    { $$ = LSCPSERVER->MoveDbInstrumentDirectory($3,$5); }
# Line 358  copy_instruction      :  DB_INSTRUMENT_D Line 470  copy_instruction      :  DB_INSTRUMENT_D
470  destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP number  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); }  destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP number  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); }
471                        |  MIDI_INPUT_DEVICE SP number    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);   }                        |  MIDI_INPUT_DEVICE SP number    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);   }
472                        |  FX_SEND SP sampler_channel SP fx_send_id  { $$ = LSCPSERVER->DestroyFxSend($3,$5); }                        |  FX_SEND SP sampler_channel SP fx_send_id  { $$ = LSCPSERVER->DestroyFxSend($3,$5); }
473                          |  EFFECT_INSTANCE SP number      { $$ = LSCPSERVER->DestroyEffectInstance($3);    }
474                        ;                        ;
475    
476  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }
477                        |  ENGINE SP load_engine_args     { $$ = $3; }                        |  ENGINE SP load_engine_args     { $$ = $3; }
478                        ;                        ;
479    
480    append_instruction    :  SEND_EFFECT_CHAIN SP EFFECT SP device_index SP effect_chain SP effect_instance  { $$ = LSCPSERVER->AppendSendEffectChainEffect($5,$7,$9); }
481                          ;
482    
483    insert_instruction    :  SEND_EFFECT_CHAIN SP EFFECT SP device_index SP effect_chain SP chain_pos SP effect_instance  { $$ = LSCPSERVER->InsertSendEffectChainEffect($5,$7,$9,$11); }
484                          ;
485    
486  set_chan_instruction  :  AUDIO_OUTPUT_DEVICE SP sampler_channel SP device_index                                              { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3);      }  set_chan_instruction  :  AUDIO_OUTPUT_DEVICE SP sampler_channel SP device_index                                              { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3);      }
487                        |  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_channel_index SP audio_channel_index               { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }                        |  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_channel_index SP audio_channel_index               { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }
488                        |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type_name                                      { $$ = LSCPSERVER->SetAudioOutputType($5, $3);        }                        |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type_name                                      { $$ = LSCPSERVER->SetAudioOutputType($5, $3);        }
# Line 401  buffer_size_type      :  BYTES       { $ Line 520  buffer_size_type      :  BYTES       { $
520  list_instruction      :  AUDIO_OUTPUT_DEVICES                               { $$ = LSCPSERVER->GetAudioOutputDevices();              }  list_instruction      :  AUDIO_OUTPUT_DEVICES                               { $$ = LSCPSERVER->GetAudioOutputDevices();              }
521                        |  MIDI_INPUT_DEVICES                                 { $$ = LSCPSERVER->GetMidiInputDevices();                }                        |  MIDI_INPUT_DEVICES                                 { $$ = LSCPSERVER->GetMidiInputDevices();                }
522                        |  CHANNELS                                           { $$ = LSCPSERVER->ListChannels();                       }                        |  CHANNELS                                           { $$ = LSCPSERVER->ListChannels();                       }
523                          |  CHANNEL SP MIDI_INPUTS SP sampler_channel          { $$ = LSCPSERVER->ListChannelMidiInputs($5);            }
524                        |  AVAILABLE_ENGINES                                  { $$ = LSCPSERVER->ListAvailableEngines();               }                        |  AVAILABLE_ENGINES                                  { $$ = LSCPSERVER->ListAvailableEngines();               }
525                          |  AVAILABLE_EFFECTS                                  { $$ = LSCPSERVER->ListAvailableEffects();               }
526                          |  EFFECT_INSTANCES                                   { $$ = LSCPSERVER->ListEffectInstances();                }
527                          |  SEND_EFFECT_CHAINS SP number                       { $$ = LSCPSERVER->ListSendEffectChains($3);             }
528                        |  AVAILABLE_MIDI_INPUT_DRIVERS                       { $$ = LSCPSERVER->ListAvailableMidiInputDrivers();      }                        |  AVAILABLE_MIDI_INPUT_DRIVERS                       { $$ = LSCPSERVER->ListAvailableMidiInputDrivers();      }
529                        |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                     { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers();    }                        |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                     { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers();    }
530                        |  MIDI_INSTRUMENTS SP midi_map                       { $$ = LSCPSERVER->ListMidiInstrumentMappings($3);       }                        |  MIDI_INSTRUMENTS SP midi_map                       { $$ = LSCPSERVER->ListMidiInstrumentMappings($3);       }
# Line 415  list_instruction      :  AUDIO_OUTPUT_DE Line 538  list_instruction      :  AUDIO_OUTPUT_DE
538                        |  FILE SP INSTRUMENTS SP filename                    { $$ = LSCPSERVER->ListFileInstruments($5);              }                        |  FILE SP INSTRUMENTS SP filename                    { $$ = LSCPSERVER->ListFileInstruments($5);              }
539                        ;                        ;
540    
541    send_instruction      :  CHANNEL SP MIDI_DATA SP string SP sampler_channel SP number SP number  { $$ = LSCPSERVER->SendChannelMidiData($5, $7, $9, $11); }
542                          ;
543    
544  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);       }
545                        |  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); }
546                        ;                        ;
# Line 427  instr_load_mode       :  ON_DEMAND Line 553  instr_load_mode       :  ON_DEMAND
553                        |  PERSISTENT      { $$ = MidiInstrumentMapper::PERSISTENT;     }                        |  PERSISTENT      { $$ = MidiInstrumentMapper::PERSISTENT;     }
554                        ;                        ;
555    
556    effect_instance           : number
557                              ;
558    
559  device_index              :  number  device_index              :  number
560                            ;                            ;
561    
# Line 462  volume_value              :  dotnum Line 591  volume_value              :  dotnum
591                            |  number  { $$ = $1; }                            |  number  { $$ = $1; }
592                            ;                            ;
593    
594    control_value             :  real
595                              ;
596    
597  sampler_channel           :  number  sampler_channel           :  number
598                            ;                            ;
599    
# Line 496  entry_name                :  stringval_e Line 628  entry_name                :  stringval_e
628  fx_send_name              :  stringval_escaped  fx_send_name              :  stringval_escaped
629                            ;                            ;
630    
631    effect_name               :  stringval_escaped
632                              ;
633    
634    effect_index              :  number
635                              ;
636    
637    effect_chain              :  number
638                              ;
639    
640    chain_pos                 :  number
641                              ;
642    
643    input_control             :  number
644                              ;
645    
646  param_val_list            :  param_val  param_val_list            :  param_val
647                            |  param_val_list','param_val  { $$ = $1 + "," + $3; }                            |  param_val_list','param_val  { $$ = $1 + "," + $3; }
648                            ;                            ;
# Line 504  param_val_list            :  param_val Line 651  param_val_list            :  param_val
651  param_val                 :  string            { $$ = "\'" + $1 + "\'"; }  param_val                 :  string            { $$ = "\'" + $1 + "\'"; }
652                            |  stringval         { $$ = "\'" + $1 + "\'"; }                            |  stringval         { $$ = "\'" + $1 + "\'"; }
653                            |  number            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); }                            |  number            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); }
654                            |  dotnum            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); }                            |  dotnum            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } //TODO: maybe better using 'real' instead of 'number' and 'dotnum' rules
655                            ;                            ;
656    
657  query_val_list            :  string '=' query_val                    { $$[$1] = $3;          }  query_val_list            :  string '=' query_val                    { $$[$1] = $3;          }
# Line 520  scan_mode                 :  RECURSIVE Line 667  scan_mode                 :  RECURSIVE
667                            |  FLAT           { $$ = "FLAT"; }                            |  FLAT           { $$ = "FLAT"; }
668                            ;                            ;
669    
670    effect_system             :  string
671                              ;
672    
673    module                    :  filename
674                              ;
675    
676  // GRAMMAR_BNF_END - do NOT delete or modify this line !!!  // GRAMMAR_BNF_END - do NOT delete or modify this line !!!
677    
678    
# Line 534  dotnum                :      digits '.' Line 687  dotnum                :      digits '.'
687                        |  '-' digits '.' digits  { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }                        |  '-' digits '.' digits  { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
688                        ;                        ;
689    
690    real                  :      digits '.' digits  { std::stringstream ss($1 + "." + $3); ss.imbue(std::locale::classic()); ss >> $$; }
691                          |  '+' digits '.' digits  { std::stringstream ss($2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
692                          |  '-' digits '.' digits  { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
693                          |      digits             { std::stringstream ss($1); ss.imbue(std::locale::classic()); ss >> $$;                  }
694                          |  '+' digits             { std::stringstream ss($2); ss.imbue(std::locale::classic()); ss >> $$;                  }
695                          |  '-' digits             { std::stringstream ss("-" + $2); ss.imbue(std::locale::classic()); ss >> $$;            }
696                          ;
697    
698    
699  digits                :  digit         { $$ = $1;      }  digits                :  digit         { $$ = $1;      }
700                        |  digits digit  { $$ = $1 + $2; }                        |  digits digit  { $$ = $1 + $2; }
# Line 722  CLEAR                 :  'C''L''E''A''R' Line 883  CLEAR                 :  'C''L''E''A''R'
883  FIND                  :  'F''I''N''D'  FIND                  :  'F''I''N''D'
884                        ;                        ;
885    
886    FILE_AS_DIR           :  'F''I''L''E''_''A''S''_''D''I''R'
887                          ;
888    
889  MOVE                  :  'M''O''V''E'  MOVE                  :  'M''O''V''E'
890                        ;                        ;
891    
# Line 758  REMOVE                :  'R''E''M''O''V' Line 922  REMOVE                :  'R''E''M''O''V'
922  SET                   :  'S''E''T'  SET                   :  'S''E''T'
923                        ;                        ;
924    
925    SHELL                 :  'S''H''E''L''L'
926                          ;
927    
928    INTERACT              :  'I''N''T''E''R''A''C''T'
929                          ;
930    
931    APPEND                :  'A''P''P''E''N''D'
932                          ;
933    
934    INSERT                :  'I''N''S''E''R''T'
935                          ;
936    
937  SUBSCRIBE             :  'S''U''B''S''C''R''I''B''E'  SUBSCRIBE             :  'S''U''B''S''C''R''I''B''E'
938                        ;                        ;
939    
# Line 815  DB_INSTRUMENT_COUNT           :  'D''B'' Line 991  DB_INSTRUMENT_COUNT           :  'D''B''
991  DB_INSTRUMENT_INFO            :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''I''N''F''O'  DB_INSTRUMENT_INFO            :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''I''N''F''O'
992                                ;                                ;
993    
994    DB_INSTRUMENT_FILES           :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''F''I''L''E''S'
995                                  ;
996    
997  DB_INSTRUMENTS_JOB_INFO       :  'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B''_''I''N''F''O'  DB_INSTRUMENTS_JOB_INFO       :  'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B''_''I''N''F''O'
998                                ;                                ;
999    
# Line 857  TOTAL_VOICE_COUNT_MAX:  'T''O''T''A''L'' Line 1036  TOTAL_VOICE_COUNT_MAX:  'T''O''T''A''L''
1036  GLOBAL_INFO          :  'G''L''O''B''A''L''_''I''N''F''O'  GLOBAL_INFO          :  'G''L''O''B''A''L''_''I''N''F''O'
1037                       ;                       ;
1038    
1039    EFFECT_INSTANCE_COUNT   :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''_''C''O''U''N''T'
1040                            ;
1041    
1042    EFFECT_INSTANCE_INFO    :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''_''I''N''F''O'
1043                            ;
1044    
1045    SEND_EFFECT_CHAIN_COUNT :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''_''C''O''U''N''T'
1046                            ;
1047    
1048    SEND_EFFECT_CHAIN_INFO  :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''_''I''N''F''O'
1049                            ;
1050    
1051  INSTRUMENT           :  'I''N''S''T''R''U''M''E''N''T'  INSTRUMENT           :  'I''N''S''T''R''U''M''E''N''T'
1052                       ;                       ;
1053    
# Line 899  AUDIO_OUTPUT_CHANNEL  :  'A''U''D''I''O' Line 1090  AUDIO_OUTPUT_CHANNEL  :  'A''U''D''I''O'
1090  AUDIO_OUTPUT_TYPE     :  'A''U''D''I''O''_''O''U''T''P''U''T''_''T''Y''P''E'  AUDIO_OUTPUT_TYPE     :  'A''U''D''I''O''_''O''U''T''P''U''T''_''T''Y''P''E'
1091                        ;                        ;
1092    
1093    AVAILABLE_EFFECTS :  'A''V''A''I''L''A''B''L''E''_''E''F''F''E''C''T''S'
1094                      ;
1095    
1096    EFFECT :  'E''F''F''E''C''T'
1097           ;
1098    
1099    EFFECT_INSTANCE :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E'
1100                    ;
1101    
1102    EFFECT_INSTANCES :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''S'
1103                     ;
1104    
1105    EFFECT_INSTANCE_INPUT_CONTROL :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''_''I''N''P''U''T''_''C''O''N''T''R''O''L'
1106                                  ;
1107    
1108    SEND_EFFECT_CHAIN :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N'
1109                      ;
1110    
1111    SEND_EFFECT_CHAINS :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''S'
1112                       ;
1113    
1114  AVAILABLE_MIDI_INPUT_DRIVERS  :  'A''V''A''I''L''A''B''L''E''_''M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R''S'  AVAILABLE_MIDI_INPUT_DRIVERS  :  'A''V''A''I''L''A''B''L''E''_''M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R''S'
1115                                ;                                ;
1116    
# Line 944  MIDI_INPUT_TYPE       :  'M''I''D''I''_' Line 1156  MIDI_INPUT_TYPE       :  'M''I''D''I''_'
1156  MIDI_INPUT            :  'M''I''D''I''_''I''N''P''U''T'  MIDI_INPUT            :  'M''I''D''I''_''I''N''P''U''T'
1157                        ;                        ;
1158    
1159    MIDI_INPUTS           :  'M''I''D''I''_''I''N''P''U''T''S'
1160                          ;
1161    
1162  MIDI_CONTROLLER       :  'M''I''D''I''_''C''O''N''T''R''O''L''L''E''R'  MIDI_CONTROLLER       :  'M''I''D''I''_''C''O''N''T''R''O''L''L''E''R'
1163                        ;                        ;
1164    
1165    SEND                  :  'S''E''N''D'
1166                          ;
1167    
1168  FX_SEND               :  'F''X''_''S''E''N''D'  FX_SEND               :  'F''X''_''S''E''N''D'
1169                        ;                        ;
1170    
# Line 986  RECURSIVE                  :  'R''E''C'' Line 1204  RECURSIVE                  :  'R''E''C''
1204  NON_RECURSIVE              :  'N''O''N''_''R''E''C''U''R''S''I''V''E'  NON_RECURSIVE              :  'N''O''N''_''R''E''C''U''R''S''I''V''E'
1205                             ;                             ;
1206    
1207    LOST                       :  'L''O''S''T'
1208                               ;
1209    
1210    FILE_PATH                  :  'F''I''L''E''_''P''A''T''H'
1211                               ;
1212    
1213  SERVER                :  'S''E''R''V''E''R'  SERVER                :  'S''E''R''V''E''R'
1214                        ;                        ;
1215    
# Line 995  VOLUME                :  'V''O''L''U''M' Line 1219  VOLUME                :  'V''O''L''U''M'
1219  LEVEL                 :  'L''E''V''E''L'  LEVEL                 :  'L''E''V''E''L'
1220                        ;                        ;
1221    
1222    VALUE                 :  'V''A''L''U''E'
1223                          ;
1224    
1225  MUTE                  :  'M''U''T''E'  MUTE                  :  'M''U''T''E'
1226                        ;                        ;
1227    
1228  SOLO                  :  'S''O''L''O'  SOLO                  :  'S''O''L''O'
1229                        ;                        ;
1230    
1231    VOICES                :  'V''O''I''C''E''S'
1232                          ;
1233    
1234    STREAMS               :  'S''T''R''E''A''M''S'
1235                          ;
1236    
1237  BYTES                 :  'B''Y''T''E''S'  BYTES                 :  'B''Y''T''E''S'
1238                        ;                        ;
1239    
# Line 1016  EDIT                  :  'E''D''I''T' Line 1249  EDIT                  :  'E''D''I''T'
1249  FORMAT                :  'F''O''R''M''A''T'  FORMAT                :  'F''O''R''M''A''T'
1250                        ;                        ;
1251    
1252    MIDI_DATA             :  'M''I''D''I''_''D''A''T''A'
1253                          ;
1254    
1255  RESET                 :  'R''E''S''E''T'  RESET                 :  'R''E''S''E''T'
1256                        ;                        ;
1257    
# Line 1033  QUIT                  :  'Q''U''I''T' Line 1269  QUIT                  :  'Q''U''I''T'
1269    
1270  %%  %%
1271    
1272    #define DEBUG_BISON_SYNTAX_ERROR_WALKER 0
1273    
1274  /**  /**
1275   * Will be called when an error occured (usually syntax error).   * Internal function, only called by yyExpectedSymbols(). It is given a Bison
1276     * parser state stack, reflecting the parser's entire state at a certain point,
1277     * i.e. when a syntax error occured. This function will then walk ahead the
1278     * potential parse tree starting from the current head of the given state
1279     * stack. This function will call itself recursively to scan the individual
1280     * parse tree branches. As soon as it hits on the next non-terminal grammar
1281     * symbol in one parse tree branch, it adds the found non-terminal symbol to
1282     * @a expectedSymbols and aborts scanning the respective tree branch further.
1283     * If any local parser state is reached a second time, the respective parse
1284     * tree is aborted to avoid any endless recursion.
1285     *
1286     * @param stack - Bison (yacc) state stack
1287     * @param expectedSymbols - will be filled with next expected grammar symbols
1288     * @param depth - just for internal debugging purposes
1289     */
1290    static void walkAndFillExpectedSymbols(std::vector<YYTYPE_INT16>& stack, std::set<String>& expectedSymbols, int depth = 0) {
1291    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1292        printf("\n");
1293        for (int i = 0; i < depth; ++i) printf("\t");
1294        printf("State stack:");
1295        for (int i = 0; i < stack.size(); ++i) {
1296            printf(" %d", stack[i]);
1297        }
1298        printf("\n");
1299    #endif
1300    
1301        if (stack.empty()) return;
1302    
1303        int state = stack[stack.size() - 1];
1304        int n = yypact[state];
1305        if (n == YYPACT_NINF) { // default reduction required ...
1306            // get default reduction rule for this state
1307            n = yydefact[state];
1308            if (n <= 0 || n >= YYNRULES) return; // no rule, something is wrong
1309            // return the new resolved expected symbol (left-hand symbol of grammar
1310            // rule), then we're done in this state
1311            expectedSymbols.insert(yytname[yyr1[n]]);
1312            return;
1313        }
1314        if (!(YYPACT_NINF < n && n <= YYLAST)) return;
1315    
1316    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1317        for (int i = 0; i < depth; ++i) printf("\t");
1318        printf("Expected tokens:");
1319    #endif
1320        int begin = n < 0 ? -n : 0;
1321        int checklim = YYLAST - n + 1;
1322        int end = checklim < YYNTOKENS ? checklim : YYNTOKENS;
1323        int rule, action, stackSize;
1324        for (int token = begin; token < end; ++token) {
1325            if (token == YYTERROR || yycheck[n + token] != token) continue;
1326    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1327            printf(" %s", yytname[token]);
1328    #endif
1329    
1330            //if (yycheck[n + token] != token) goto default_reduction;
1331    
1332            action = yytable[n + token];
1333            if (action == 0 || action == YYTABLE_NINF) {
1334    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1335                printf(" (invalid action) "); fflush(stdout);
1336    #endif
1337                continue; // error, ignore
1338            }
1339            if (action < 0) { // reduction with rule -action required ...
1340    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1341                printf(" (reduction) "); fflush(stdout);
1342    #endif
1343                rule = -action;
1344                goto reduce;
1345            }
1346            if (action == YYFINAL) continue; // "accept" state, we don't care about it here
1347    
1348            // "shift" required ...
1349    
1350            if (std::find(stack.begin(), stack.end(), action) != stack.end())
1351                continue; // duplicate state, ignore it to avoid endless recursions
1352    
1353            // "shift" / push the new state on the state stack and call this
1354            // function recursively, and restore the stack after the recurse return
1355            stackSize = stack.size();
1356            stack.push_back(action);
1357            walkAndFillExpectedSymbols( //FIXME: could cause stack overflow (should be a loop instead), is probably fine with our current grammar though
1358                stack, expectedSymbols, depth + 1
1359            );
1360            stack.resize(stackSize); // restore stack
1361            continue;
1362    
1363        //default_reduction: // resolve default reduction for this state
1364        //    printf(" (default red.) "); fflush(stdout);
1365        //    rule = yydefact[state];
1366    
1367        reduce: // "reduce" required
1368    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1369            printf(" (reduce by %d) ", rule); fflush(stdout);
1370    #endif
1371            if (rule == 0 || rule >= YYNRULES) continue; // invalid rule, something is wrong
1372            // store the left-hand symbol of the grammar rule
1373            expectedSymbols.insert(yytname[yyr1[rule]]);
1374    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1375            printf(" (SYM %s) ", yytname[yyr1[rule]]); fflush(stdout);
1376    #endif
1377        }
1378    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1379        printf("\n");
1380    #endif
1381    }
1382    
1383    inline static int _yyReduce(std::vector<YYTYPE_INT16>& stack, const int& rule) {
1384        if (stack.empty()) throw 1; // severe error
1385        const int len = yyr2[rule];
1386        stack.resize(stack.size() - len);
1387        YYTYPE_INT16 newState = yypgoto[yyr1[rule] - YYNTOKENS] + stack.back();
1388        if (0 <= newState && newState <= YYLAST && yycheck[newState] == stack.back())
1389            newState = yytable[newState];
1390        else
1391            newState = yydefgoto[yyr1[rule] - YYNTOKENS];
1392        stack.push_back(newState);
1393        return newState;
1394    }
1395    
1396    inline static int _yyDefaultReduce(std::vector<YYTYPE_INT16>& stack) {
1397        if (stack.empty()) throw 2; // severe error
1398        int rule = yydefact[stack.back()];
1399        if (rule <= 0 || rule >= YYNRULES) throw 3; // no rule, something is wrong
1400        return _yyReduce(stack, rule);
1401    }
1402    
1403    #define DEBUG_PUSH_PARSE 0
1404    
1405    static bool yyPushParse(std::vector<YYTYPE_INT16>& stack, char ch) {
1406        startLabel:
1407    
1408    #if DEBUG_PUSH_PARSE
1409        //printf("\n");
1410        //for (int i = 0; i < depth; ++i) printf("\t");
1411        printf("State stack:");
1412        for (int i = 0; i < stack.size(); ++i) {
1413            printf(" %d", stack[i]);
1414        }
1415        printf(" char='%c'(%d)\n", ch, (int)ch);
1416    #endif
1417    
1418        if (stack.empty()) return false;
1419    
1420        int state = stack.back();
1421        int n = yypact[state];
1422        if (n == YYPACT_NINF) { // default reduction required ...
1423    #if DEBUG_PUSH_PARSE
1424            printf("(def reduce 1)\n");
1425    #endif
1426            state = _yyDefaultReduce(stack);
1427            goto startLabel;
1428        }
1429        if (!(YYPACT_NINF < n && n <= YYLAST)) return false;
1430    
1431        YYTYPE_INT16 token = (ch == YYEOF) ? YYEOF : yytranslate[ch];
1432        n += token;
1433        if (n < 0 || YYLAST < n || yycheck[n] != token) {
1434    #if DEBUG_PUSH_PARSE
1435            printf("(def reduce 2) n=%d token=%d\n", n, token);
1436    #endif
1437            state = _yyDefaultReduce(stack);
1438            goto startLabel;
1439        }
1440        int action = yytable[n]; // yytable[yypact[state] + token]
1441        if (action == 0 || action == YYTABLE_NINF) throw 4;
1442        if (action < 0) {
1443    #if DEBUG_PUSH_PARSE
1444            printf("(reduce)\n");
1445    #endif
1446            int rule = -action;
1447            state = _yyReduce(stack, rule);
1448            goto startLabel;
1449        }
1450        if (action == YYFINAL) return true; // final state reached
1451    
1452    #if DEBUG_PUSH_PARSE
1453        printf("(push)\n");
1454    #endif
1455        // push new state
1456        state = action;
1457        stack.push_back(state);
1458        return true;
1459    }
1460    
1461    static bool yyValid(std::vector<YYTYPE_INT16>& stack, char ch) {
1462        try {
1463            return yyPushParse(stack, ch);
1464        } catch (int i) {
1465    #if DEBUG_PUSH_PARSE
1466            printf("exception %d\n", i);
1467    #endif
1468            return false;
1469        } catch (...) {
1470            return false;
1471        }
1472    }
1473    
1474    static int yyValidCharacters(std::vector<YYTYPE_INT16>& stack, const String& line) {
1475        int i;
1476        for (i = 0; i < line.size(); ++i) {
1477            if (!yyValid(stack, line[i])) return i;
1478        }
1479        return i;
1480    }
1481    
1482    /**
1483     * Should only be called on syntax errors: returns a set of non-terminal
1484     * symbols expected to appear now/next, just at the point where the syntax
1485     * error appeared.
1486   */   */
1487  void yyerror(const char* s) {  static std::set<String> yyExpectedSymbols() {
1488        std::set<String> result;
1489      yyparse_param_t* param = GetCurrentYaccSession();      yyparse_param_t* param = GetCurrentYaccSession();
1490      String msg = s      YYTYPE_INT16* ss = (*param->ppStackBottom);
1491          + (" (line:"   + ToString(param->iLine+1))      YYTYPE_INT16* sp = (*param->ppStackTop);
1492          + ( ",column:" + ToString(param->iColumn))      int iStackSize   = sp - ss + 1;
1493          + ")";      // copy and wrap parser's state stack into a convenient STL container
1494      dmsg(2,("LSCPParser: %s\n", msg.c_str()));      std::vector<YYTYPE_INT16> stack;
1495      sLastError = msg;      for (int i = 0; i < iStackSize; ++i) {
1496            stack.push_back(ss[i]);
1497        }
1498        // do the actual parser work
1499        walkAndFillExpectedSymbols(stack, result);
1500        return result;
1501    }
1502    
1503    namespace LinuxSampler {
1504    
1505    String lscpParserProcessShellInteraction(String& line, yyparse_param_t* param) {
1506        std::vector<YYTYPE_INT16> stack;
1507        stack.push_back(0); // every Bison symbol stack starts with zero
1508        String l = line + '\n';
1509        int n = yyValidCharacters(stack, l);
1510        String result = line;
1511        result.insert(n <= result.length() ? n : result.length(), LSCP_SHK_GOOD_FRONT);
1512        int code = (n > line.length()) ? LSCP_SHU_COMPLETE : (n < line.length()) ?
1513                   LSCP_SHU_SYNTAX_ERR : LSCP_SHU_INCOMPLETE;
1514        result = "SHU:" + ToString(code) + ":" + result;
1515        //if (n > line.length()) result += " [OK]";
1516    #if DEBUG_PUSH_PARSE
1517        printf("%s\n", result.c_str());
1518    #endif
1519        return result;
1520  }  }
1521    
1522  /**  /**
# Line 1053  void restart(yyparse_param_t* pparam, in Line 1526  void restart(yyparse_param_t* pparam, in
1526      bytes = 0;      bytes = 0;
1527      ptr   = 0;      ptr   = 0;
1528      sLastError = "";      sLastError = "";
1529        sParsed = "";
1530    }
1531    
1532  }  }

Legend:
Removed from v.1695  
changed lines
  Added in v.2515

  ViewVC Help
Powered by ViewVC