/[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 210 by schoenebeck, Sat Jul 24 12:33:49 2004 UTC revision 2510 by schoenebeck, Thu Jan 23 04:00:26 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 - 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 20  Line 21 
21   *   MA  02111-1307  USA                                                   *   *   MA  02111-1307  USA                                                   *
22   ***************************************************************************/   ***************************************************************************/
23    
24  /* Note: don't forget to run 'make parser' after you changed this file, */  /*
25  /*       otherwise the parser will not be regenerated!                  */      The parser's C++ source files should be automatically (re)generated if
26        this file was modified. If not, or in case you want explicitly
27        regenerate the parser C++ files, run 'make parser'. In both cases you
28        need to have bison or another yacc compatible parser generator
29        installed though.
30    */
31    
32  %{  %{
33    
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    
40  // as we need an reentrant scanner, we have to pass the pointer to the scanner with each yylex() call  namespace LinuxSampler {
 #define YYLEX_PARAM ((yyparse_param_t*) yyparse_param)->pScanner  
41    
42  // to save us typing work in the rules action definitions  // to save us typing work in the rules action definitions
43  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer
44    #define SESSION_PARAM ((yyparse_param_t*) yyparse_param)
45    #define INCREMENT_LINE { SESSION_PARAM->iLine++; SESSION_PARAM->iColumn = 0; sParsed.clear(); }
46    
47  // clears input buffer and restarts scanner.  // clears input buffer
48  void restart(yyparse_param_t* pparam, int& yychar);  void restart(yyparse_param_t* pparam, int& yychar);
49  #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar)  #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar)
50    
51  // external reference to the main scanner function yylex()  static char buf[1024]; // input buffer to feed the parser with new characters
52  extern YY_DECL;  static int bytes = 0;  // current number of characters in the input buffer
53    static int ptr   = 0;  // current position in the input buffer
54    static String sLastError; // error message of the last error occured
55    static String sParsed; ///< Characters of current line which have already been shifted (consumed/parsed) by the parser.
56    
57    // external reference to the function which actually reads from the socket
58    extern int GetLSCPCommand( void *buf, int max_size);
59    
60    // external reference to the function in lscpserver.cpp which returns the
61    // current session (only works because the server runs as singleton)
62    extern yyparse_param_t* GetCurrentYaccSession();
63    
64    // returns true if supplied characters has an ASCII code of 128 or higher
65    inline bool isExtendedAsciiChar(const char c) {
66        return (c < 0);
67    }
68    
69    // custom scanner function which reads from the socket
70    // (bison expects it to return the numerical ID of the next
71    // "recognized token" from the input stream)
72    int yylex(YYSTYPE* yylval) {
73        // check if we have to read new characters
74        if (ptr >= bytes) {
75            bytes = GetLSCPCommand(buf, 1023);
76            ptr   = 0;
77            if (bytes < 0) {
78                bytes = 0;
79                return 0;
80            }
81        }
82        // this is the next character in the input stream
83        const char c = buf[ptr++];
84        // increment current reading position (just for verbosity / messages)
85        GetCurrentYaccSession()->iColumn++;
86        sParsed += c;
87        // we have to handle "normal" and "extended" ASCII characters separately
88        if (isExtendedAsciiChar(c)) {
89            // workaround for characters with ASCII code higher than 127
90            yylval->Char = c;
91            return EXT_ASCII_CHAR;
92        } else {
93            // simply return the ASCII code as terminal symbol ID
94            return (int) c;
95        }
96    }
97    
98    // parser helper functions
99    
100    int octalsToNumber(char oct_digit0, char oct_digit1 = '0', char oct_digit2 = '0') {
101        const char d0[] = { oct_digit0, '\0' };
102        const char d1[] = { oct_digit1, '\0' };
103        const char d2[] = { oct_digit2, '\0' };
104        return atoi(d2)*8*8 + atoi(d1)*8 + atoi(d0);
105    }
106    
107    }
108    
109    using namespace LinuxSampler;
110    
111    static std::set<String> yyExpectedSymbols();
112    
113  // external reference to restart the lex scanner  /**
114  extern void yyrestart(FILE* input_file, yyscan_t yyscanner);   * Will be called when an error occured (usually syntax error).
115     *
116     * We provide our own version of yyerror() so we a) don't have to link against
117     * the yacc library and b) can render more helpful syntax error messages.
118     */
119    void yyerror(void* x, const char* s) {
120        yyparse_param_t* param = GetCurrentYaccSession();
121    
122  // we provide our own version of yyerror() so we don't have to link against the yacc library      // get the text part already parsed (of current line)
123  void yyerror(const char* s);      const bool bContainsLineFeed =
124            sParsed.find('\r') != std::string::npos ||
125            sParsed.find('\n') != std::string::npos;
126        // remove potential line feed characters
127        if (bContainsLineFeed) {
128            for (size_t p = sParsed.find('\r'); p != std::string::npos;
129                 p = sParsed.find('\r')) sParsed.erase(p);
130            for (size_t p = sParsed.find('\n'); p != std::string::npos;
131                 p = sParsed.find('\n')) sParsed.erase(p);
132        }
133    
134        // start assembling the error message with Bison's own message
135        String txt = s;
136    
137        // append exact position info of syntax error
138        txt += (" (line:"  + ToString(param->iLine+1)) +
139               (",column:" + ToString(param->iColumn)) + ")";
140    
141        // append the part of the lined that has already been parsed
142        txt += ". Context: \"" + sParsed;
143        if (txt.empty() || bContainsLineFeed)
144            txt += "^";
145        else
146            txt.insert(txt.size() - 1, "^");
147        txt += "...\"";
148    
149        // append the non-terminal symbols expected now/next
150        std::set<String> expectedSymbols = yyExpectedSymbols();
151        for (std::set<String>::const_iterator it = expectedSymbols.begin();
152             it != expectedSymbols.end(); ++it)
153        {
154            if (it == expectedSymbols.begin())
155                txt += " -> Should be: " + *it;
156            else
157                txt += " | " + *it;
158        }
159    
160        dmsg(2,("LSCPParser: %s\n", txt.c_str()));
161        sLastError = txt;
162    }
163    
164  %}  %}
165    
166  // reentrant parser  // reentrant parser
167  %pure_parser  %pure-parser
168    
169    %parse-param {void* yyparse_param}
170    
171    // After entering the yyparse() function, store references to the parser's
172    // state stack, so that we can create more helpful syntax error messages than
173    // Bison (2.x) could do.
174    %initial-action {
175        yyparse_param_t* p = (yyparse_param_t*) yyparse_param;
176        p->ppStackBottom = &yyss;
177        p->ppStackTop    = &yyssp;
178    }
179    
180    // tell bison to spit out verbose syntax error messages
181    %error-verbose
182    
183    %token <Char> EXT_ASCII_CHAR
184    
185  %token <Char>   CHAR  %type <Char> char char_base alpha_char digit digit_oct digit_hex escape_seq escape_seq_octal escape_seq_hex
186  %token <Dotnum> DOTNUM  %type <Dotnum> real dotnum volume_value boolean control_value
187  %token <Number> NUMBER  %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
188  %token <String> STRINGVAL  %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
 %token SP LF CR HASH EQ  
 %token ADD GET CREATE DESTROY LIST LOAD NON_MODAL REMOVE SET SUBSCRIBE UNSUBSCRIBE RESET ECHO QUIT  
 %token CHANNEL NOTIFICATION  
 %token AVAILABLE_ENGINES AVAILABLE_AUDIO_OUTPUT_DRIVERS CHANNELS INFO BUFFER_FILL STREAM_COUNT VOICE_COUNT  
 %token INSTRUMENT ENGINE  
 %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  
 %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  
 %token BYTES PERCENTAGE  
 %token MISCELLANEOUS  
   
 %type <Dotnum> volume boolean  
 %type <Number> sampler_channel instrument_index audio_output_channel audio_output_device midi_input_channel midi_input_port midi_input_device  
 %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  
189  %type <FillResponse> buffer_size_type  %type <FillResponse> buffer_size_type
190  %type <KeyValList> key_val_list  %type <KeyValList> key_val_list query_val_list
191    %type <LoadMode> instr_load_mode
192    %type <Bool> modal_arg
193    %type <UniversalPath> path path_base path_prefix path_body
194    
195  %start input  %start input
196    
# Line 79  void yyerror(const char* s); Line 198  void yyerror(const char* s);
198    
199  //TODO: return more meaningful error messages  //TODO: return more meaningful error messages
200    
201    /*
202      The LSCP specification document input file (Documentation/lscp.xml) is
203      automatically updated with this file using the scripts/update_grammar.pl
204      script. Do not modify or delete the GRAMMAR_BNF_BEGIN and GRAMMAR_BNF_END
205      lines !
206    */
207    
208    // GRAMMAR_BNF_BEGIN - do NOT delete or modify this line !!!
209    
210  input                 : line LF  input                 : line LF
211                          | line CR LF
212                          ;
213    
214  line                  :  /* epsilon (empty line ignored) */ { return LSCP_DONE; }  line                  :  /* epsilon (empty line ignored) */ { INCREMENT_LINE; return LSCP_DONE; }
215                        |  comment  { return LSCP_DONE; }                        |  comment  { INCREMENT_LINE; return LSCP_DONE; }
216                        |  command  { LSCPSERVER->AnswerClient($1); return LSCP_DONE; }                        |  command  { INCREMENT_LINE; LSCPSERVER->AnswerClient($1); return LSCP_DONE; }
217                        |  error    { LSCPSERVER->AnswerClient("Err:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; }                        |  error    { INCREMENT_LINE; LSCPSERVER->AnswerClient("ERR:0:" + sLastError + "\r\n"); RESTART; return LSCP_SYNTAX_ERROR; }
218                        ;                        ;
219    
220  comment               :  HASH  comment               :  '#'
221                        |  comment HASH                        |  comment '#'
222                        |  comment SP                        |  comment SP
223                        |  comment NUMBER                        |  comment number
224                        |  comment string                        |  comment string
225                        ;                        ;
226    
227  command               :  ADD SP CHANNEL                             { $$ = LSCPSERVER->AddChannel();                  }  command               :  ADD SP add_instruction                { $$ = $3;                                                }
228                        |  GET SP get_instruction                     { $$ = $3;                                        }                        |  MAP SP map_instruction                { $$ = $3;                                                }
229                        |  CREATE SP create_instruction               { $$ = $3;                                        }                        |  UNMAP SP unmap_instruction            { $$ = $3;                                                }
230                        |  DESTROY SP destroy_instruction             { $$ = $3;                                        }                        |  GET SP get_instruction                { $$ = $3;                                                }
231                        |  LIST SP list_instruction                   { $$ = $3;                                        }                        |  CREATE SP create_instruction          { $$ = $3;                                                }
232                        |  LOAD SP load_instruction                   { $$ = $3;                                        }                        |  DESTROY SP destroy_instruction        { $$ = $3;                                                }
233                        |  REMOVE SP CHANNEL SP sampler_channel       { $$ = LSCPSERVER->RemoveChannel($5);             }                        |  LIST SP list_instruction              { $$ = $3;                                                }
234                        |  SET SP set_instruction                     { $$ = $3;                                        }                        |  LOAD SP load_instruction              { $$ = $3;                                                }
235                        |  SUBSCRIBE SP subscribe_event               { $$ = $3;                                        }                        |  REMOVE SP remove_instruction          { $$ = $3;                                                }
236                        |  UNSUBSCRIBE SP unsubscribe_event           { $$ = $3;                                        }                        |  SET SP set_instruction                { $$ = $3;                                                }
237                        |  RESET SP CHANNEL SP sampler_channel        { $$ = LSCPSERVER->ResetChannel($5);              }                        |  SUBSCRIBE SP subscribe_event          { $$ = $3;                                                }
238                        |  QUIT                                       { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }                        |  UNSUBSCRIBE SP unsubscribe_event      { $$ = $3;                                                }
239                        ;                        |  RESET SP reset_instruction            { $$ = $3;                                                }
240                          |  CLEAR SP clear_instruction            { $$ = $3;                                                }
241  subscribe_event       :  CHANNELS                                   { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channels); }                        |  FIND SP find_instruction              { $$ = $3;                                                }
242                        |  VOICE_COUNT                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); }                        |  MOVE SP move_instruction              { $$ = $3;                                                }
243                        |  STREAM_COUNT                               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); }                        |  COPY SP copy_instruction              { $$ = $3;                                                }
244                        |  BUFFER_FILL                                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); }                        |  EDIT SP edit_instruction              { $$ = $3;                                                }
245                        |  INFO                                       { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_info); }                        |  FORMAT SP format_instruction          { $$ = $3;                                                }
246                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); }                        |  SEND SP send_instruction              { $$ = $3;                                                }
247                        ;                        |  APPEND SP append_instruction          { $$ = $3;                                                }
248                          |  INSERT SP insert_instruction          { $$ = $3;                                                }
249  unsubscribe_event     :  CHANNELS                                   { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channels); }                        |  RESET                                 { $$ = LSCPSERVER->ResetSampler();                        }
250                        |  VOICE_COUNT                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); }                        |  QUIT                                  { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; }
251                        |  STREAM_COUNT                               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); }                        ;
252                        |  BUFFER_FILL                                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); }  
253                        |  INFO                                       { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_info); }  add_instruction       :  CHANNEL                               { $$ = LSCPSERVER->AddChannel();                  }
254                        |  MISCELLANEOUS                              { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); }                        |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index                           { $$ = LSCPSERVER->AddChannelMidiInput($5,$7);    }
255                        ;                        |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index SP midi_input_port_index  { $$ = LSCPSERVER->AddChannelMidiInput($5,$7,$9); }
256                          |  DB_INSTRUMENT_DIRECTORY SP db_path    { $$ = LSCPSERVER->AddDbInstrumentDirectory($3);  }
257  get_instruction       :  AVAILABLE_ENGINES                          { $$ = LSCPSERVER->GetAvailableEngines();       }                        |  DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP db_path SP filename                        { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);        }
258                        |  AVAILABLE_MIDI_INPUT_DRIVERS               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();       }                        |  DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP FILE_AS_DIR SP db_path SP filename         { $$ = LSCPSERVER->AddDbInstruments($5,$9,$11, true, true); }
259                        |  MIDI_INPUT_DRIVER SP INFO SP string        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);       }                        |  DB_INSTRUMENTS SP scan_mode SP db_path SP filename                                     { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);              }
260                        |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string     { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7);       }                        |  DB_INSTRUMENTS SP scan_mode SP FILE_AS_DIR SP db_path SP filename                      { $$ = LSCPSERVER->AddDbInstruments($3,$7,$9, false, true); }
261                        |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list    { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7, $9);       }                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename                                     { $$ = LSCPSERVER->AddDbInstruments($5,$7, -1, true);       }
262                        |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                                             { $$ = LSCPSERVER->GetAvailableAudioOutputDrivers();       }                        |  DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename SP instrument_index                 { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true);        }
263                        |  AUDIO_OUTPUT_DRIVER SP INFO SP string                                      { $$ = LSCPSERVER->GetAudioOutputDriverInfo($5);       }                        |  DB_INSTRUMENTS SP db_path SP filename                                                  { $$ = LSCPSERVER->AddDbInstruments($3,$5);                 }
264                        |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string                  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7);       }                        |  DB_INSTRUMENTS SP db_path SP filename SP instrument_index                              { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7);              }
265                        |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7, $9);       }                        |  MIDI_INSTRUMENT_MAP                   { $$ = LSCPSERVER->AddMidiInstrumentMap();                }
266                        |  AUDIO_OUTPUT_DEVICES                                                       { $$ = LSCPSERVER->GetAudioOutputDeviceCount();       }                        |  MIDI_INSTRUMENT_MAP SP map_name       { $$ = LSCPSERVER->AddMidiInstrumentMap($3);              }
267                        |  MIDI_INPUT_DEVICES                                                         { $$ = LSCPSERVER->GetMidiInputDeviceCount();       }                        |  SEND_EFFECT_CHAIN SP device_index     { $$ = LSCPSERVER->AddSendEffectChain($3);                }
268                        |  AUDIO_OUTPUT_DEVICE SP INFO SP NUMBER                                      { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5);       }                        ;
269                        |  MIDI_INPUT_DEVICE SP INFO SP NUMBER                                        { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5);       }  
270                        |  MIDI_INPUT_PORT SP INFO SP NUMBER SP NUMBER                                { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7);       }  subscribe_event       :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_audio_device_count);   }
271                        |  MIDI_INPUT_PORT_PARAMETER SP INFO SP NUMBER SP NUMBER SP string            { $$ = LSCPSERVER->GetMidiInputPortParameterInfo($5, $7, $9);       }                        |  AUDIO_OUTPUT_DEVICE_INFO              { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_audio_device_info);    }
272                        |  AUDIO_OUTPUT_CHANNEL SP INFO SP NUMBER SP NUMBER                           { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7);       }                        |  MIDI_INPUT_DEVICE_COUNT               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_device_count);    }
273                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP NUMBER SP NUMBER SP string       { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9);       }                        |  MIDI_INPUT_DEVICE_INFO                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_device_info);     }
274                        |  CHANNELS                                                                   { $$ = LSCPSERVER->GetChannels();       }                        |  CHANNEL_COUNT                         { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_count);        }
275                        |  CHANNEL SP INFO SP sampler_channel                                         { $$ = LSCPSERVER->GetChannelInfo($5);       }                        |  CHANNEL_MIDI                          { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_midi);         }
276                        |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel              { $$ = LSCPSERVER->GetBufferFill($5, $7);       }                        |  DEVICE_MIDI                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_device_midi);          }
277                        |  CHANNEL SP STREAM_COUNT SP sampler_channel                                 { $$ = LSCPSERVER->GetStreamCount($5);       }                        |  VOICE_COUNT                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count);          }
278                        |  CHANNEL SP VOICE_COUNT SP sampler_channel                                  { $$ = LSCPSERVER->GetVoiceCount($5);       }                        |  STREAM_COUNT                          { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count);         }
279                        |  ENGINE SP INFO SP engine_name                                              { $$ = LSCPSERVER->GetEngineInfo($5);       }                        |  BUFFER_FILL                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill);          }
280                        ;                        |  CHANNEL_INFO                          { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_info);         }
281                          |  FX_SEND_COUNT                         { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_send_count);        }
282  set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);       }                        |  FX_SEND_INFO                          { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_send_info);         }
283                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9);       }                        |  MIDI_INSTRUMENT_MAP_COUNT             { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_instr_map_count); }
284                        |  MIDI_INPUT_DEVICE_PARAMETER SP NUMBER SP string EQ param_val               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);       }                        |  MIDI_INSTRUMENT_MAP_INFO              { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_instr_map_info);  }
285                        |  MIDI_INPUT_PORT_PARAMETER SP NUMBER SP NUMBER SP string EQ param_val       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);       }                        |  MIDI_INSTRUMENT_COUNT                 { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_instr_count);     }
286                        |  CHANNEL SP set_chan_instruction                                            { $$ = $3;                                                         }                        |  MIDI_INSTRUMENT_INFO                  { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_instr_info);      }
287                        |  ECHO SP boolean                                                            { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3);  }                        |  DB_INSTRUMENT_DIRECTORY_COUNT         { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instr_dir_count);   }
288                        ;                        |  DB_INSTRUMENT_DIRECTORY_INFO          { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instr_dir_info);    }
289                          |  DB_INSTRUMENT_COUNT                   { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instr_count);       }
290  create_instruction    :  AUDIO_OUTPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }                        |  DB_INSTRUMENT_INFO                    { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instr_info);        }
291                        |  AUDIO_OUTPUT_DEVICE SP string                 { $$ = LSCPSERVER->CreateAudioOutputDevice($3);    }                        |  DB_INSTRUMENTS_JOB_INFO               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instrs_job_info);   }
292                        |  MIDI_INPUT_DEVICE SP string SP key_val_list   { $$ = LSCPSERVER->CreateMidiInputDevice($3,$5);   }                        |  MISCELLANEOUS                         { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc);                 }
293                        |  MIDI_INPUT_DEVICE SP string                   { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }                        |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_stream_count);   }
294                        ;                        |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_voice_count);    }
295                          |  GLOBAL_INFO                           { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_global_info);          }
296  destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP NUMBER  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3);       }                        |  EFFECT_INSTANCE_COUNT                 { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_instance_count);    }
297                        |  MIDI_INPUT_DEVICE SP NUMBER    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);         }                        |  EFFECT_INSTANCE_INFO                  { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_fx_instance_info);     }
298                          |  SEND_EFFECT_CHAIN_COUNT               { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_send_fx_chain_count);  }
299                          |  SEND_EFFECT_CHAIN_INFO                { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_send_fx_chain_info);   }
300                          ;
301    
302    unsubscribe_event     :  AUDIO_OUTPUT_DEVICE_COUNT             { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_audio_device_count);   }
303                          |  AUDIO_OUTPUT_DEVICE_INFO              { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_audio_device_info);    }
304                          |  MIDI_INPUT_DEVICE_COUNT               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_device_count);    }
305                          |  MIDI_INPUT_DEVICE_INFO                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_device_info);     }
306                          |  CHANNEL_COUNT                         { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_count);        }
307                          |  CHANNEL_MIDI                          { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_midi);         }
308                          |  DEVICE_MIDI                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_device_midi);          }
309                          |  VOICE_COUNT                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count);          }
310                          |  STREAM_COUNT                          { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count);         }
311                          |  BUFFER_FILL                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill);          }
312                          |  CHANNEL_INFO                          { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_info);         }
313                          |  FX_SEND_COUNT                         { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_send_count);        }
314                          |  FX_SEND_INFO                          { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_send_info);         }
315                          |  MIDI_INSTRUMENT_MAP_COUNT             { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_instr_map_count); }
316                          |  MIDI_INSTRUMENT_MAP_INFO              { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_instr_map_info);  }
317                          |  MIDI_INSTRUMENT_COUNT                 { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_instr_count);     }
318                          |  MIDI_INSTRUMENT_INFO                  { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_instr_info);      }
319                          |  DB_INSTRUMENT_DIRECTORY_COUNT         { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instr_dir_count);   }
320                          |  DB_INSTRUMENT_DIRECTORY_INFO          { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instr_dir_info);    }
321                          |  DB_INSTRUMENT_COUNT                   { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instr_count);       }
322                          |  DB_INSTRUMENT_INFO                    { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instr_info);        }
323                          |  DB_INSTRUMENTS_JOB_INFO               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instrs_job_info);   }
324                          |  MISCELLANEOUS                         { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc);                 }
325                          |  TOTAL_STREAM_COUNT                    { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_stream_count);   }
326                          |  TOTAL_VOICE_COUNT                     { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_voice_count);    }
327                          |  GLOBAL_INFO                           { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_global_info);          }
328                          |  EFFECT_INSTANCE_COUNT                 { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_instance_count);    }
329                          |  EFFECT_INSTANCE_INFO                  { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_fx_instance_info);     }
330                          |  SEND_EFFECT_CHAIN_COUNT               { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_send_fx_chain_count);  }
331                          |  SEND_EFFECT_CHAIN_INFO                { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_send_fx_chain_info);   }
332                          ;
333    
334    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); }
335                          |  MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP instr_load_mode { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,$18,"",$3); }
336                          |  MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP entry_name { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,MidiInstrumentMapper::DONTCARE,$18,$3); }
337                          |  MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value SP instr_load_mode SP entry_name { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,$18,$20,$3); }
338                          ;
339    
340    unmap_instruction     :  MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog  { $$ = LSCPSERVER->RemoveMIDIInstrumentMapping($3,$5,$7); }
341                          ;
342    
343    remove_instruction    :  CHANNEL SP sampler_channel                   { $$ = LSCPSERVER->RemoveChannel($3);                      }
344                          |  CHANNEL SP MIDI_INPUT SP sampler_channel                                           { $$ = LSCPSERVER->RemoveChannelMidiInput($5);       }
345                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index                           { $$ = LSCPSERVER->RemoveChannelMidiInput($5,$7);    }
346                          |  CHANNEL SP MIDI_INPUT SP sampler_channel SP device_index SP midi_input_port_index  { $$ = LSCPSERVER->RemoveChannelMidiInput($5,$7,$9); }
347                          |  MIDI_INSTRUMENT_MAP SP midi_map              { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3);            }
348                          |  MIDI_INSTRUMENT_MAP SP ALL                   { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps();          }
349                          |  SEND_EFFECT_CHAIN SP device_index SP effect_chain  { $$ = LSCPSERVER->RemoveSendEffectChain($3,$5);     }
350                          |  SEND_EFFECT_CHAIN SP EFFECT SP device_index SP effect_chain SP chain_pos  { $$ = LSCPSERVER->RemoveSendEffectChainEffect($5,$7,$9); }
351                          |  FX_SEND SP EFFECT SP sampler_channel SP fx_send_id  { $$ = LSCPSERVER->SetFxSendEffect($5,$7,-1,-1);    }
352                          |  DB_INSTRUMENT_DIRECTORY SP FORCE SP db_path  { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($5, true);  }
353                          |  DB_INSTRUMENT_DIRECTORY SP db_path           { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($3);        }
354                          |  DB_INSTRUMENT SP db_path                     { $$ = LSCPSERVER->RemoveDbInstrument($3);                 }
355                          ;
356    
357    get_instruction       :  AVAILABLE_ENGINES                                                          { $$ = LSCPSERVER->GetAvailableEngines();                          }
358                          |  AVAILABLE_EFFECTS                                                          { $$ = LSCPSERVER->GetAvailableEffects();                          }
359                          |  EFFECT_INSTANCES                                                           { $$ = LSCPSERVER->GetEffectInstances();                           }
360                          |  EFFECT SP INFO SP effect_index                                             { $$ = LSCPSERVER->GetEffectInfo($5);                              }
361                          |  EFFECT_INSTANCE SP INFO SP effect_instance                                 { $$ = LSCPSERVER->GetEffectInstanceInfo($5);                      }
362                          |  EFFECT_INSTANCE_INPUT_CONTROL SP INFO SP effect_instance SP input_control  { $$ = LSCPSERVER->GetEffectInstanceInputControlInfo($5,$7);       }
363                          |  SEND_EFFECT_CHAINS SP device_index                                         { $$ = LSCPSERVER->GetSendEffectChains($3);                        }
364                          |  SEND_EFFECT_CHAIN SP INFO SP device_index SP effect_chain                  { $$ = LSCPSERVER->GetSendEffectChainInfo($5,$7);                  }
365                          |  AVAILABLE_MIDI_INPUT_DRIVERS                                               { $$ = LSCPSERVER->GetAvailableMidiInputDrivers();                 }
366                          |  MIDI_INPUT_DRIVER SP INFO SP string                                        { $$ = LSCPSERVER->GetMidiInputDriverInfo($5);                     }
367                          |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string                    { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7);        }
368                          |  MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list    { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7, $9);    }
369                          |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                                             { $$ = LSCPSERVER->GetAvailableAudioOutputDrivers();               }
370                          |  AUDIO_OUTPUT_DRIVER SP INFO SP string                                      { $$ = LSCPSERVER->GetAudioOutputDriverInfo($5);                   }
371                          |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string                  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7);      }
372                          |  AUDIO_OUTPUT_DRIVER_PARAMETER SP INFO SP string SP string SP key_val_list  { $$ = LSCPSERVER->GetAudioOutputDriverParameterInfo($5, $7, $9);  }
373                          |  AUDIO_OUTPUT_DEVICES                                                       { $$ = LSCPSERVER->GetAudioOutputDeviceCount();                    }
374                          |  MIDI_INPUT_DEVICES                                                         { $$ = LSCPSERVER->GetMidiInputDeviceCount();                      }
375                          |  AUDIO_OUTPUT_DEVICE SP INFO SP number                                      { $$ = LSCPSERVER->GetAudioOutputDeviceInfo($5);                   }
376                          |  MIDI_INPUT_DEVICE SP INFO SP number                                        { $$ = LSCPSERVER->GetMidiInputDeviceInfo($5);                     }
377                          |  MIDI_INPUT_PORT SP INFO SP number SP number                                { $$ = LSCPSERVER->GetMidiInputPortInfo($5, $7);                   }
378                          |  MIDI_INPUT_PORT_PARAMETER SP INFO SP number SP number SP string            { $$ = LSCPSERVER->GetMidiInputPortParameterInfo($5, $7, $9);      }
379                          |  AUDIO_OUTPUT_CHANNEL SP INFO SP number SP number                           { $$ = LSCPSERVER->GetAudioOutputChannelInfo($5, $7);              }
380                          |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP INFO SP number SP number SP string       { $$ = LSCPSERVER->GetAudioOutputChannelParameterInfo($5, $7, $9); }
381                          |  CHANNELS                                                                   { $$ = LSCPSERVER->GetChannels();                                  }
382                          |  CHANNEL SP INFO SP sampler_channel                                         { $$ = LSCPSERVER->GetChannelInfo($5);                             }
383                          |  CHANNEL SP BUFFER_FILL SP buffer_size_type SP sampler_channel              { $$ = LSCPSERVER->GetBufferFill($5, $7);                          }
384                          |  CHANNEL SP STREAM_COUNT SP sampler_channel                                 { $$ = LSCPSERVER->GetStreamCount($5);                             }
385                          |  CHANNEL SP VOICE_COUNT SP sampler_channel                                  { $$ = LSCPSERVER->GetVoiceCount($5);                              }
386                          |  ENGINE SP INFO SP engine_name                                              { $$ = LSCPSERVER->GetEngineInfo($5);                              }
387                          |  SERVER SP INFO                                                             { $$ = LSCPSERVER->GetServerInfo();                                }
388                          |  TOTAL_STREAM_COUNT                                                         { $$ = LSCPSERVER->GetTotalStreamCount();                           }
389                          |  TOTAL_VOICE_COUNT                                                          { $$ = LSCPSERVER->GetTotalVoiceCount();                           }
390                          |  TOTAL_VOICE_COUNT_MAX                                                      { $$ = LSCPSERVER->GetTotalVoiceCountMax();                        }
391                          |  MIDI_INSTRUMENTS SP midi_map                                               { $$ = LSCPSERVER->GetMidiInstrumentMappings($3);                  }
392                          |  MIDI_INSTRUMENTS SP ALL                                                    { $$ = LSCPSERVER->GetAllMidiInstrumentMappings();                 }
393                          |  MIDI_INSTRUMENT SP INFO SP midi_map SP midi_bank SP midi_prog              { $$ = LSCPSERVER->GetMidiInstrumentMapping($5,$7,$9);             }
394                          |  MIDI_INSTRUMENT_MAPS                                                       { $$ = LSCPSERVER->GetMidiInstrumentMaps();                        }
395                          |  MIDI_INSTRUMENT_MAP SP INFO SP midi_map                                    { $$ = LSCPSERVER->GetMidiInstrumentMap($5);                       }
396                          |  FX_SENDS SP sampler_channel                                                { $$ = LSCPSERVER->GetFxSends($3);                                 }
397                          |  FX_SEND SP INFO SP sampler_channel SP fx_send_id                           { $$ = LSCPSERVER->GetFxSendInfo($5,$7);                           }
398                          |  DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP db_path                          { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($5, true);        }
399                          |  DB_INSTRUMENT_DIRECTORIES SP db_path                                       { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($3, false);       }
400                          |  DB_INSTRUMENT_DIRECTORY SP INFO SP db_path                                 { $$ = LSCPSERVER->GetDbInstrumentDirectoryInfo($5);               }
401                          |  DB_INSTRUMENTS SP RECURSIVE SP db_path                                     { $$ = LSCPSERVER->GetDbInstrumentCount($5, true);                 }
402                          |  DB_INSTRUMENTS SP db_path                                                  { $$ = LSCPSERVER->GetDbInstrumentCount($3, false);                }
403                          |  DB_INSTRUMENT SP INFO SP db_path                                           { $$ = LSCPSERVER->GetDbInstrumentInfo($5);                        }
404                          |  DB_INSTRUMENTS_JOB SP INFO SP number                                       { $$ = LSCPSERVER->GetDbInstrumentsJobInfo($5);                    }
405                          |  VOLUME                                                                     { $$ = LSCPSERVER->GetGlobalVolume();                              }
406                          |  VOICES                                                                     { $$ = LSCPSERVER->GetGlobalMaxVoices();                           }
407                          |  STREAMS                                                                    { $$ = LSCPSERVER->GetGlobalMaxStreams();                          }
408                          |  FILE SP INSTRUMENTS SP filename                                            { $$ = LSCPSERVER->GetFileInstruments($5);                         }
409                          |  FILE SP INSTRUMENT SP INFO SP filename SP instrument_index                 { $$ = LSCPSERVER->GetFileInstrumentInfo($7,$9);                   }
410                          ;
411    
412    set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);      }
413                          |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val_list  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); }
414                          |  MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);        }
415                          |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' NONE                 { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, "");      }
416                          |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);      }
417                          |  EFFECT_INSTANCE_INPUT_CONTROL SP VALUE SP effect_instance SP input_control SP control_value  { $$ = LSCPSERVER->SetEffectInstanceInputControlValue($5, $7, $9); }
418                          |  CHANNEL SP set_chan_instruction                                                  { $$ = $3;                                                         }
419                          |  MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name                              { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7);               }
420                          |  FX_SEND SP NAME SP sampler_channel SP fx_send_id SP fx_send_name                 { $$ = LSCPSERVER->SetFxSendName($5,$7,$9);                        }
421                          |  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); }
422                          |  FX_SEND SP MIDI_CONTROLLER SP sampler_channel SP fx_send_id SP midi_ctrl         { $$ = LSCPSERVER->SetFxSendMidiController($5,$7,$9);              }
423                          |  FX_SEND SP LEVEL SP sampler_channel SP fx_send_id SP volume_value                { $$ = LSCPSERVER->SetFxSendLevel($5,$7,$9);                       }
424                          |  FX_SEND SP EFFECT SP sampler_channel SP fx_send_id SP effect_chain SP chain_pos  { $$ = LSCPSERVER->SetFxSendEffect($5,$7,$9,$11);                  }
425                          |  DB_INSTRUMENT_DIRECTORY SP NAME SP db_path SP stringval_escaped                  { $$ = LSCPSERVER->SetDbInstrumentDirectoryName($5,$7);            }
426                          |  DB_INSTRUMENT_DIRECTORY SP DESCRIPTION SP db_path SP stringval_escaped           { $$ = LSCPSERVER->SetDbInstrumentDirectoryDescription($5,$7);     }
427                          |  DB_INSTRUMENT SP NAME SP db_path SP stringval_escaped                            { $$ = LSCPSERVER->SetDbInstrumentName($5,$7);                     }
428                          |  DB_INSTRUMENT SP DESCRIPTION SP db_path SP stringval_escaped                     { $$ = LSCPSERVER->SetDbInstrumentDescription($5,$7);              }
429                          |  DB_INSTRUMENT SP FILE_PATH SP filename SP filename                               { $$ = LSCPSERVER->SetDbInstrumentFilePath($5,$7);                 }
430                          |  ECHO SP boolean                                                                  { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3);  }
431                          |  VOLUME SP volume_value                                                           { $$ = LSCPSERVER->SetGlobalVolume($3);                            }
432                          |  VOICES SP number                                                                 { $$ = LSCPSERVER->SetGlobalMaxVoices($3);                         }
433                          |  STREAMS SP number                                                                { $$ = LSCPSERVER->SetGlobalMaxStreams($3);                        }
434                          ;
435    
436    create_instruction    :  AUDIO_OUTPUT_DEVICE SP string SP key_val_list  { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); }
437                          |  AUDIO_OUTPUT_DEVICE SP string                  { $$ = LSCPSERVER->CreateAudioOutputDevice($3);    }
438                          |  MIDI_INPUT_DEVICE SP string SP key_val_list    { $$ = LSCPSERVER->CreateMidiInputDevice($3,$5);   }
439                          |  MIDI_INPUT_DEVICE SP string                    { $$ = LSCPSERVER->CreateMidiInputDevice($3);      }
440                          |  FX_SEND SP sampler_channel SP midi_ctrl        { $$ = LSCPSERVER->CreateFxSend($3,$5);            }
441                          |  FX_SEND SP sampler_channel SP midi_ctrl SP fx_send_name  { $$ = LSCPSERVER->CreateFxSend($3,$5,$7); }
442                          |  EFFECT_INSTANCE SP effect_index                { $$ = LSCPSERVER->CreateEffectInstance($3);       }
443                          |  EFFECT_INSTANCE SP effect_system SP module SP effect_name  { $$ = LSCPSERVER->CreateEffectInstance($3,$5,$7); }
444                          ;
445    
446    reset_instruction     :  CHANNEL SP sampler_channel  { $$ = LSCPSERVER->ResetChannel($3); }
447                          ;
448    
449    clear_instruction     :  MIDI_INSTRUMENTS SP midi_map   { $$ = LSCPSERVER->ClearMidiInstrumentMappings($3);  }
450                          |  MIDI_INSTRUMENTS SP ALL        { $$ = LSCPSERVER->ClearAllMidiInstrumentMappings(); }
451                          ;
452    
453    find_instruction      :  DB_INSTRUMENTS SP NON_RECURSIVE SP db_path SP query_val_list              { $$ = LSCPSERVER->FindDbInstruments($5,$7, false);           }
454                          |  DB_INSTRUMENTS SP db_path SP query_val_list                               { $$ = LSCPSERVER->FindDbInstruments($3,$5, true);            }
455                          |  DB_INSTRUMENT_DIRECTORIES SP NON_RECURSIVE SP db_path SP query_val_list   { $$ = LSCPSERVER->FindDbInstrumentDirectories($5,$7, false); }
456                          |  DB_INSTRUMENT_DIRECTORIES SP db_path SP query_val_list                    { $$ = LSCPSERVER->FindDbInstrumentDirectories($3,$5, true);  }
457                          |  LOST SP DB_INSTRUMENT_FILES                                               { $$ = LSCPSERVER->FindLostDbInstrumentFiles();                 }
458                          ;
459    
460    move_instruction      :  DB_INSTRUMENT_DIRECTORY SP db_path SP db_path    { $$ = LSCPSERVER->MoveDbInstrumentDirectory($3,$5); }
461                          |  DB_INSTRUMENT SP db_path SP db_path              { $$ = LSCPSERVER->MoveDbInstrument($3,$5);          }
462                          ;
463    
464    copy_instruction      :  DB_INSTRUMENT_DIRECTORY SP db_path SP db_path    { $$ = LSCPSERVER->CopyDbInstrumentDirectory($3,$5); }
465                          |  DB_INSTRUMENT SP db_path SP db_path              { $$ = LSCPSERVER->CopyDbInstrument($3,$5);          }
466                          ;
467    
468    destroy_instruction   :  AUDIO_OUTPUT_DEVICE SP number  { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); }
469                          |  MIDI_INPUT_DEVICE SP number    { $$ = LSCPSERVER->DestroyMidiInputDevice($3);   }
470                          |  FX_SEND SP sampler_channel SP fx_send_id  { $$ = LSCPSERVER->DestroyFxSend($3,$5); }
471                          |  EFFECT_INSTANCE SP number      { $$ = LSCPSERVER->DestroyEffectInstance($3);    }
472                        ;                        ;
473    
474  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }  load_instruction      :  INSTRUMENT SP load_instr_args  { $$ = $3; }
475                        |  ENGINE SP load_engine_args     { $$ = $3; }                        |  ENGINE SP load_engine_args     { $$ = $3; }
476                        ;                        ;
477    
478  set_chan_instruction  :  AUDIO_OUTPUT_DEVICE SP sampler_channel SP audio_output_device                            { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3);      }  append_instruction    :  SEND_EFFECT_CHAIN SP EFFECT SP device_index SP effect_chain SP effect_instance  { $$ = LSCPSERVER->AppendSendEffectChainEffect($5,$7,$9); }
                       |  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_output_channel SP audio_output_channel  { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }  
                       |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type                                { $$ = LSCPSERVER->SetAudioOutputType($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);  }  
                       |  MIDI_INPUT_DEVICE SP sampler_channel SP midi_input_device                                { $$ = LSCPSERVER->SetMIDIInputDevice($5, $3);        }  
                       |  MIDI_INPUT_PORT SP sampler_channel SP midi_input_port                                    { $$ = LSCPSERVER->SetMIDIInputPort($5, $3);          }  
                       |  MIDI_INPUT_CHANNEL SP sampler_channel SP midi_input_channel                              { $$ = LSCPSERVER->SetMIDIInputChannel($5, $3);       }  
                       |  MIDI_INPUT_TYPE SP sampler_channel SP midi_input_type                                    { $$ = LSCPSERVER->SetMIDIInputType($5, $3);          }  
                       |  VOLUME SP sampler_channel SP volume                                                      { $$ = LSCPSERVER->SetVolume($5, $3);                 }  
479                        ;                        ;
480    
481  key_val_list          :  string EQ param_val                  { $$[$1] = $3;          }  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); }
482                        |  key_val_list SP string EQ param_val  { $$ = $1; $$[$3] = $5; }                        ;
483    
484    set_chan_instruction  :  AUDIO_OUTPUT_DEVICE SP sampler_channel SP device_index                                              { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3);      }
485                          |  AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_channel_index SP audio_channel_index               { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); }
486                          |  AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type_name                                      { $$ = LSCPSERVER->SetAudioOutputType($5, $3);        }
487                          |  MIDI_INPUT SP sampler_channel SP device_index SP midi_input_port_index SP midi_input_channel_index  { $$ = LSCPSERVER->SetMIDIInput($5, $7, $9, $3);      }
488                          |  MIDI_INPUT_DEVICE SP sampler_channel SP device_index                                                { $$ = LSCPSERVER->SetMIDIInputDevice($5, $3);        }
489                          |  MIDI_INPUT_PORT SP sampler_channel SP midi_input_port_index                                         { $$ = LSCPSERVER->SetMIDIInputPort($5, $3);          }
490                          |  MIDI_INPUT_CHANNEL SP sampler_channel SP midi_input_channel_index                                   { $$ = LSCPSERVER->SetMIDIInputChannel($5, $3);       }
491                          |  MIDI_INPUT_TYPE SP sampler_channel SP midi_input_type_name                                          { $$ = LSCPSERVER->SetMIDIInputType($5, $3);          }
492                          |  VOLUME SP sampler_channel SP volume_value                                                           { $$ = LSCPSERVER->SetVolume($5, $3);                 }
493                          |  MUTE SP sampler_channel SP boolean                                                                  { $$ = LSCPSERVER->SetChannelMute($5, $3);            }
494                          |  SOLO SP sampler_channel SP boolean                                                                  { $$ = LSCPSERVER->SetChannelSolo($5, $3);            }
495                          |  MIDI_INSTRUMENT_MAP SP sampler_channel SP midi_map                                                  { $$ = LSCPSERVER->SetChannelMap($3, $5);             }
496                          |  MIDI_INSTRUMENT_MAP SP sampler_channel SP NONE                                                      { $$ = LSCPSERVER->SetChannelMap($3, -1);             }
497                          |  MIDI_INSTRUMENT_MAP SP sampler_channel SP DEFAULT                                                   { $$ = LSCPSERVER->SetChannelMap($3, -2);             }
498                          ;
499    
500    edit_instruction      :  CHANNEL SP INSTRUMENT SP sampler_channel  { $$ = LSCPSERVER->EditSamplerChannelInstrument($5); }
501                          ;
502    
503    format_instruction    :  INSTRUMENTS_DB  { $$ = LSCPSERVER->FormatInstrumentsDb(); }
504                          ;
505    
506    modal_arg             :  /* epsilon (empty argument) */  { $$ = true;  }
507                          |  NON_MODAL SP                    { $$ = false; }
508                          ;
509    
510    key_val_list          :  string '=' param_val_list                  { $$[$1] = $3;          }
511                          |  key_val_list SP string '=' param_val_list  { $$ = $1; $$[$3] = $5; }
512                        ;                        ;
513    
514  buffer_size_type      :  BYTES       { $$ = fill_response_bytes;      }  buffer_size_type      :  BYTES       { $$ = fill_response_bytes;      }
515                        |  PERCENTAGE  { $$ = fill_response_percentage; }                        |  PERCENTAGE  { $$ = fill_response_percentage; }
516                        ;                        ;
517    
518  list_instruction      :  AUDIO_OUTPUT_DEVICES  { $$ = LSCPSERVER->GetAudioOutputDevices(); }  list_instruction      :  AUDIO_OUTPUT_DEVICES                               { $$ = LSCPSERVER->GetAudioOutputDevices();              }
519                        |  MIDI_INPUT_DEVICES    { $$ = LSCPSERVER->GetMidiInputDevices();   }                        |  MIDI_INPUT_DEVICES                                 { $$ = LSCPSERVER->GetMidiInputDevices();                }
520                        |  CHANNELS              { $$ = LSCPSERVER->ListChannels();          }                        |  CHANNELS                                           { $$ = LSCPSERVER->ListChannels();                       }
521                          |  CHANNEL SP MIDI_INPUTS SP sampler_channel          { $$ = LSCPSERVER->ListChannelMidiInputs($5);            }
522                          |  AVAILABLE_ENGINES                                  { $$ = LSCPSERVER->ListAvailableEngines();               }
523                          |  AVAILABLE_EFFECTS                                  { $$ = LSCPSERVER->ListAvailableEffects();               }
524                          |  EFFECT_INSTANCES                                   { $$ = LSCPSERVER->ListEffectInstances();                }
525                          |  SEND_EFFECT_CHAINS SP number                       { $$ = LSCPSERVER->ListSendEffectChains($3);             }
526                          |  AVAILABLE_MIDI_INPUT_DRIVERS                       { $$ = LSCPSERVER->ListAvailableMidiInputDrivers();      }
527                          |  AVAILABLE_AUDIO_OUTPUT_DRIVERS                     { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers();    }
528                          |  MIDI_INSTRUMENTS SP midi_map                       { $$ = LSCPSERVER->ListMidiInstrumentMappings($3);       }
529                          |  MIDI_INSTRUMENTS SP ALL                            { $$ = LSCPSERVER->ListAllMidiInstrumentMappings();      }
530                          |  MIDI_INSTRUMENT_MAPS                               { $$ = LSCPSERVER->ListMidiInstrumentMaps();             }
531                          |  FX_SENDS SP sampler_channel                        { $$ = LSCPSERVER->ListFxSends($3);                      }
532                          |  DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP db_path  { $$ = LSCPSERVER->GetDbInstrumentDirectories($5, true); }
533                          |  DB_INSTRUMENT_DIRECTORIES SP db_path               { $$ = LSCPSERVER->GetDbInstrumentDirectories($3);       }
534                          |  DB_INSTRUMENTS SP RECURSIVE SP db_path             { $$ = LSCPSERVER->GetDbInstruments($5, true);           }
535                          |  DB_INSTRUMENTS SP db_path                          { $$ = LSCPSERVER->GetDbInstruments($3);                 }
536                          |  FILE SP INSTRUMENTS SP filename                    { $$ = LSCPSERVER->ListFileInstruments($5);              }
537                        ;                        ;
538    
539  load_instr_args       :  filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($1, $3, $5);       }  send_instruction      :  CHANNEL SP MIDI_DATA SP string SP sampler_channel SP number SP number  { $$ = LSCPSERVER->SendChannelMidiData($5, $7, $9, $11); }
                       |  NON_MODAL SP filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true);       }  
540                        ;                        ;
541    
542  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);       }
543                          |  NON_MODAL SP filename SP instrument_index SP sampler_channel  { $$ = LSCPSERVER->LoadInstrument($3, $5, $7, true); }
544                        ;                        ;
545    
546  audio_output_device   :  NUMBER  load_engine_args      :  engine_name SP sampler_channel  { $$ = LSCPSERVER->SetEngineType($1, $3); }
547                        ;                        ;
548    
549  audio_output_channel  :  NUMBER  instr_load_mode       :  ON_DEMAND       { $$ = MidiInstrumentMapper::ON_DEMAND;      }
550                          |  ON_DEMAND_HOLD  { $$ = MidiInstrumentMapper::ON_DEMAND_HOLD; }
551                          |  PERSISTENT      { $$ = MidiInstrumentMapper::PERSISTENT;     }
552                        ;                        ;
553    
554  audio_output_type     :  string  effect_instance           : number
555                              ;
556    
557    device_index              :  number
558                              ;
559    
560    audio_channel_index       :  number
561                              ;
562    
563    audio_output_type_name    :  string
564                              ;
565    
566    midi_input_port_index     :  number
567                              ;
568    
569    midi_input_channel_index  :  number
570                              |  ALL  { $$ = 16; }
571                              ;
572    
573    midi_input_type_name      :  string
574                              ;
575    
576    midi_map                  :  number
577                              ;
578    
579    midi_bank                 :  number
580                              ;
581    
582    midi_prog                 :  number
583                              ;
584    
585    midi_ctrl                 :  number
586                              ;
587    
588    volume_value              :  dotnum
589                              |  number  { $$ = $1; }
590                              ;
591    
592    control_value             :  real
593                              ;
594    
595    sampler_channel           :  number
596                              ;
597    
598    instrument_index          :  number
599                              ;
600    
601    fx_send_id                :  number
602                              ;
603    
604    engine_name               :  string
605                              ;
606    
607    filename                  :  path  {
608                                     #if WIN32
609                                     $$ = $1.toWindows();
610                                     #else
611                                     // assuming POSIX
612                                     $$ = $1.toPosix();
613                                     #endif
614                                 }
615                              ;
616    
617    db_path                   :  path  { $$ = $1.toDbPath(); }
618                              ;
619    
620    map_name                  :  stringval_escaped
621                              ;
622    
623    entry_name                :  stringval_escaped
624                              ;
625    
626    fx_send_name              :  stringval_escaped
627                              ;
628    
629    effect_name               :  stringval_escaped
630                              ;
631    
632    effect_index              :  number
633                              ;
634    
635    effect_chain              :  number
636                              ;
637    
638    chain_pos                 :  number
639                              ;
640    
641    input_control             :  number
642                              ;
643    
644    param_val_list            :  param_val
645                              |  param_val_list','param_val  { $$ = $1 + "," + $3; }
646                              ;
647    
648    //TODO: the re-encapsulation into apostrophes for string and strinval here is a hack, since we need a way for __parse_strings() (DeviceParameters.cpp) to distinguish a comma separated list of strings and a string which contains commas. A clean solution would be to move those parser jobs over here to lscp.y
649    param_val                 :  string            { $$ = "\'" + $1 + "\'"; }
650                              |  stringval         { $$ = "\'" + $1 + "\'"; }
651                              |  number            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); }
652                              |  dotnum            { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } //TODO: maybe better using 'real' instead of 'number' and 'dotnum' rules
653                              ;
654    
655    query_val_list            :  string '=' query_val                    { $$[$1] = $3;          }
656                              |  query_val_list SP string '=' query_val  { $$ = $1; $$[$3] = $5; }
657                              ;
658    
659    query_val                 :  text_escaped
660                              |  stringval_escaped
661                              ;
662    
663    scan_mode                 :  RECURSIVE      { $$ = "RECURSIVE"; }
664                              |  NON_RECURSIVE  { $$ = "NON_RECURSIVE"; }
665                              |  FLAT           { $$ = "FLAT"; }
666                              ;
667    
668    effect_system             :  string
669                              ;
670    
671    module                    :  filename
672                              ;
673    
674    // GRAMMAR_BNF_END - do NOT delete or modify this line !!!
675    
676    
677    // atomic variable symbol rules
678    
679    boolean               :  number  { $$ = $1; }
680                          |  string  { $$ = -1; }
681                        ;                        ;
682    
683  midi_input_device     :  NUMBER  dotnum                :      digits '.' digits  { std::stringstream ss($1 + "." + $3); ss.imbue(std::locale::classic()); ss >> $$; }
684                          |  '+' digits '.' digits  { std::stringstream ss($2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
685                          |  '-' digits '.' digits  { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
686                        ;                        ;
687    
688  midi_input_port       :  NUMBER  real                  :      digits '.' digits  { std::stringstream ss($1 + "." + $3); ss.imbue(std::locale::classic()); ss >> $$; }
689                          |  '+' digits '.' digits  { std::stringstream ss($2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
690                          |  '-' digits '.' digits  { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; }
691                          |      digits             { std::stringstream ss($1); ss.imbue(std::locale::classic()); ss >> $$;                  }
692                          |  '+' digits             { std::stringstream ss($2); ss.imbue(std::locale::classic()); ss >> $$;                  }
693                          |  '-' digits             { std::stringstream ss("-" + $2); ss.imbue(std::locale::classic()); ss >> $$;            }
694                        ;                        ;
695    
696  midi_input_channel    :  NUMBER  
697    digits                :  digit         { $$ = $1;      }
698                          |  digits digit  { $$ = $1 + $2; }
699                        ;                        ;
700    
701  midi_input_type       :  string  digit                 :  '0'  { $$ = '0'; }
702                          |  '1'  { $$ = '1'; }
703                          |  '2'  { $$ = '2'; }
704                          |  '3'  { $$ = '3'; }
705                          |  '4'  { $$ = '4'; }
706                          |  '5'  { $$ = '5'; }
707                          |  '6'  { $$ = '6'; }
708                          |  '7'  { $$ = '7'; }
709                          |  '8'  { $$ = '8'; }
710                          |  '9'  { $$ = '9'; }
711                        ;                        ;
712    
713  volume                :  DOTNUM  digit_oct             :  '0'  { $$ = '0'; }
714                        |  NUMBER  { $$ = $1; }                        |  '1'  { $$ = '1'; }
715                          |  '2'  { $$ = '2'; }
716                          |  '3'  { $$ = '3'; }
717                          |  '4'  { $$ = '4'; }
718                          |  '5'  { $$ = '5'; }
719                          |  '6'  { $$ = '6'; }
720                          |  '7'  { $$ = '7'; }
721                        ;                        ;
722    
723  sampler_channel       :  NUMBER  digit_hex             :  '0'  { $$ = '0'; }
724                          |  '1'  { $$ = '1'; }
725                          |  '2'  { $$ = '2'; }
726                          |  '3'  { $$ = '3'; }
727                          |  '4'  { $$ = '4'; }
728                          |  '5'  { $$ = '5'; }
729                          |  '6'  { $$ = '6'; }
730                          |  '7'  { $$ = '7'; }
731                          |  '8'  { $$ = '8'; }
732                          |  '9'  { $$ = '9'; }
733                          |  'a'  { $$ = 'a'; }
734                          |  'b'  { $$ = 'b'; }
735                          |  'c'  { $$ = 'c'; }
736                          |  'd'  { $$ = 'd'; }
737                          |  'e'  { $$ = 'e'; }
738                          |  'f'  { $$ = 'f'; }
739                          |  'A'  { $$ = 'a'; }
740                          |  'B'  { $$ = 'b'; }
741                          |  'C'  { $$ = 'c'; }
742                          |  'D'  { $$ = 'd'; }
743                          |  'E'  { $$ = 'e'; }
744                          |  'F'  { $$ = 'f'; }
745                        ;                        ;
746    
747  instrument_index      :  NUMBER  number                :  digit       { $$ = atoi(String(1, $1).c_str());      }
748                          |  '1' digits  { $$ = atoi(String(String("1") + $2).c_str()); }
749                          |  '2' digits  { $$ = atoi(String(String("2") + $2).c_str()); }
750                          |  '3' digits  { $$ = atoi(String(String("3") + $2).c_str()); }
751                          |  '4' digits  { $$ = atoi(String(String("4") + $2).c_str()); }
752                          |  '5' digits  { $$ = atoi(String(String("5") + $2).c_str()); }
753                          |  '6' digits  { $$ = atoi(String(String("6") + $2).c_str()); }
754                          |  '7' digits  { $$ = atoi(String(String("7") + $2).c_str()); }
755                          |  '8' digits  { $$ = atoi(String(String("8") + $2).c_str()); }
756                          |  '9' digits  { $$ = atoi(String(String("9") + $2).c_str()); }
757                        ;                        ;
758    
759  engine_name           :  string  path                  :  '\'' path_base '\''  { $$ = $2; }
760                          |  '\"' path_base '\"'  { $$ = $2; }
761                        ;                        ;
762    
763  filename              :  STRINGVAL  path_base             :  path_prefix path_body  { $$ = $1 + $2; }
764                        ;                        ;
765    
766  param_val             :  STRINGVAL                { $$ = $1;                                             }  path_prefix           :  '/'                 { $$ = Path();                    }
767                        |  NUMBER                   { std::stringstream ss; ss << $1; $$ = ss.str();       }                        |  alpha_char ':' '/'  { Path p; p.setDrive($1); $$ = p; }
                       |  DOTNUM                   { std::stringstream ss; ss << $1; $$ = ss.str();       }  
768                        ;                        ;
769    
770  boolean               :  NUMBER  { $$ = $1; }  path_body             :  /* epsilon (empty argument) */ { $$ = Path();                           }
771                        |  string  { $$ = -1; }                        |  path_body '/'                  { $$ = $1;                               }
772                          |  path_body text_escaped_base    { Path p; p.appendNode($2); $$ = $1 + p; }
773                          ;
774    
775    stringval             :  '\'' text '\''  { $$ = $2; }
776                          |  '\"' text '\"'  { $$ = $2; }
777                          ;
778    
779    stringval_escaped     :  '\'' text_escaped '\''  { $$ = $2; }
780                          |  '\"' text_escaped '\"'  { $$ = $2; }
781                          ;
782    
783    text                  :  SP           { $$ = " ";      }
784                          |  string
785                          |  text SP      { $$ = $1 + " "; }
786                          |  text string  { $$ = $1 + $2;  }
787                          ;
788    
789    // like text_escaped, but missing the slash ('/') character
790    text_escaped_base     :  SP                                { $$ = " ";      }
791                          |  string_escaped
792                          |  text_escaped_base SP              { $$ = $1 + " "; }
793                          |  text_escaped_base string_escaped  { $$ = $1 + $2;  }
794                          ;
795    
796    text_escaped          :  '/'                              { $$ = "/";      }
797                          |  text_escaped_base
798                          |  text_escaped '/'                 { $$ = $1 + "/"; }
799                          |  text_escaped text_escaped_base   { $$ = $1 + $2;  }
800                          ;
801    
802    string                :  char          { std::string s; s = $1; $$ = s; }
803                          |  string char   { $$ = $1 + $2;                  }
804                          ;
805    
806    string_escaped        :  char_base                   { std::string s; s = $1; $$ = s; }
807                          |  escape_seq                  { std::string s; s = $1; $$ = s; }
808                          |  string_escaped char_base    { $$ = $1 + $2;                  }
809                          |  string_escaped escape_seq   { $$ = $1 + $2;                  }
810                          ;
811    
812    // full ASCII character set except space, quotation mark and apostrophe
813    char                  :  char_base
814                          |  '\\'  { $$ = '\\'; }
815                          |  '/'   { $$ = '/';  }
816                          ;
817    
818    // characters A..Z and a..z
819    alpha_char            :  'A' { $$ = 'A'; } | 'B' { $$ = 'B'; } | 'C' { $$ = 'C'; } | 'D' { $$ = 'D'; } | 'E' { $$ = 'E'; } | 'F' { $$ = 'F'; } | 'G' { $$ = 'G'; } | 'H' { $$ = 'H'; } | 'I' { $$ = 'I'; } | 'J' { $$ = 'J'; } | 'K' { $$ = 'K'; } | 'L' { $$ = 'L'; } | 'M' { $$ = 'M'; } | 'N' { $$ = 'N'; } | 'O' { $$ = 'O'; } | 'P' { $$ = 'P'; } | 'Q' { $$ = 'Q'; } | 'R' { $$ = 'R'; } | 'S' { $$ = 'S'; } | 'T' { $$ = 'T'; } | 'U' { $$ = 'U'; } | 'V' { $$ = 'V'; } | 'W' { $$ = 'W'; } | 'X' { $$ = 'X'; } | 'Y' { $$ = 'Y'; } | 'Z' { $$ = 'Z'; }
820                          |  'a' { $$ = 'a'; } | 'b' { $$ = 'b'; } | 'c' { $$ = 'c'; } | 'd' { $$ = 'd'; } | 'e' { $$ = 'e'; } | 'f' { $$ = 'f'; } | 'g' { $$ = 'g'; } | 'h' { $$ = 'h'; } | 'i' { $$ = 'i'; } | 'j' { $$ = 'j'; } | 'k' { $$ = 'k'; } | 'l' { $$ = 'l'; } | 'm' { $$ = 'm'; } | 'n' { $$ = 'n'; } | 'o' { $$ = 'o'; } | 'p' { $$ = 'p'; } | 'q' { $$ = 'q'; } | 'r' { $$ = 'r'; } | 's' { $$ = 's'; } | 't' { $$ = 't'; } | 'u' { $$ = 'u'; } | 'v' { $$ = 'v'; } | 'w' { $$ = 'w'; } | 'x' { $$ = 'x'; } | 'y' { $$ = 'y'; } | 'z' { $$ = 'z'; }
821                          ;
822    
823    // ASCII characters except space, quotation mark, apostrophe, backslash and slash
824    char_base             :  alpha_char
825                          |  '0' { $$ = '0'; } | '1' { $$ = '1'; } | '2' { $$ = '2'; } | '3' { $$ = '3'; } | '4' { $$ = '4'; } | '5' { $$ = '5'; } | '6' { $$ = '6'; } | '7' { $$ = '7'; } | '8' { $$ = '8'; } | '9' { $$ = '9'; }
826                          |  '!' { $$ = '!'; } | '#' { $$ = '#'; } | '$' { $$ = '$'; } | '%' { $$ = '%'; } | '&' { $$ = '&'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } | '*' { $$ = '*'; } | '+' { $$ = '+'; } | '-' { $$ = '-'; } | '.' { $$ = '.'; } | ',' { $$ = ','; }
827                          |  ':' { $$ = ':'; } | ';' { $$ = ';'; } | '<' { $$ = '<'; } | '=' { $$ = '='; } | '>' { $$ = '>'; } | '?' { $$ = '?'; } | '@' { $$ = '@'; }
828                          |  '[' { $$ = '['; } | ']' { $$ = ']'; } | '^' { $$ = '^'; } | '_' { $$ = '_'; }
829                          |  '{' { $$ = '{'; } | '|' { $$ = '|'; } | '}' { $$ = '}'; } | '~' { $$ = '~'; }
830                          |  EXT_ASCII_CHAR
831                          ;
832    
833    escape_seq            :  '\\' '\''  { $$ = '\''; }
834                          |  '\\' '\"'  { $$ = '\"'; }
835                          |  '\\' '\\'  { $$ = '\\'; }
836                          |  '\\' '/'   { $$ = '/';  }
837                          |  '\\' 'n'   { $$ = '\n'; }
838                          |  '\\' 'r'   { $$ = '\r'; }
839                          |  '\\' 'f'   { $$ = '\f'; }
840                          |  '\\' 't'   { $$ = '\t'; }
841                          |  '\\' 'v'   { $$ = '\v'; }
842                          |  escape_seq_octal
843                          |  escape_seq_hex
844                          ;
845    
846    escape_seq_octal      :  '\\' digit_oct                      { $$ = (char) octalsToNumber($2);       }
847                          |  '\\' digit_oct digit_oct            { $$ = (char) octalsToNumber($3,$2);    }
848                          |  '\\' digit_oct digit_oct digit_oct  { $$ = (char) octalsToNumber($4,$3,$2); }
849                          ;
850    
851    escape_seq_hex        :  '\\' 'x' digit_hex            { $$ = (char) hexsToNumber($3);    }
852                          |  '\\' 'x' digit_hex digit_hex  { $$ = (char) hexsToNumber($4,$3); }
853                          ;
854    
855    // rules which are more or less just terminal symbols
856    
857    SP                    :  ' '
858                          ;
859    
860    LF                    :  '\n'
861                          ;
862    
863    CR                    :  '\r'
864                          ;
865    
866    ADD                   :  'A''D''D'
867                          ;
868    
869    GET                   :  'G''E''T'
870                          ;
871    
872    MAP                   :  'M''A''P'
873                          ;
874    
875    UNMAP                 :  'U''N''M''A''P'
876                          ;
877    
878    CLEAR                 :  'C''L''E''A''R'
879                          ;
880    
881    FIND                  :  'F''I''N''D'
882                          ;
883    
884    FILE_AS_DIR           :  'F''I''L''E''_''A''S''_''D''I''R'
885                          ;
886    
887    MOVE                  :  'M''O''V''E'
888                          ;
889    
890    COPY                  :  'C''O''P''Y'
891                          ;
892    
893    CREATE                :  'C''R''E''A''T''E'
894                          ;
895    
896    DESTROY               :  'D''E''S''T''R''O''Y'
897                          ;
898    
899    LIST                  :  'L''I''S''T'
900                          ;
901    
902    LOAD                  :  'L''O''A''D'
903                          ;
904    
905    ALL                   :  'A''L''L'
906                          ;
907    
908    NONE                  :  'N''O''N''E'
909                          ;
910    
911    DEFAULT               :  'D''E''F''A''U''L''T'
912                          ;
913    
914    NON_MODAL             :  'N''O''N''_''M''O''D''A''L'
915                          ;
916    
917    REMOVE                :  'R''E''M''O''V''E'
918                          ;
919    
920    SET                   :  'S''E''T'
921                          ;
922    
923    APPEND                :  'A''P''P''E''N''D'
924                          ;
925    
926    INSERT                :  'I''N''S''E''R''T'
927                          ;
928    
929    SUBSCRIBE             :  'S''U''B''S''C''R''I''B''E'
930                          ;
931    
932    UNSUBSCRIBE           :  'U''N''S''U''B''S''C''R''I''B''E'
933                        ;                        ;
934    
935  string                :  CHAR          { std::string s; s = $1; $$ = s; }  CHANNEL               :  'C''H''A''N''N''E''L'
936                        |  string CHAR   { $$ = $1 + $2;                  }                        ;
937    
938    AVAILABLE_ENGINES     :  'A''V''A''I''L''A''B''L''E''_''E''N''G''I''N''E''S'
939                          ;
940    
941    AVAILABLE_AUDIO_OUTPUT_DRIVERS  :  'A''V''A''I''L''A''B''L''E''_''A''U''D''I''O''_''O''U''T''P''U''T''_''D''R''I''V''E''R''S'
942                                    ;
943    
944    CHANNELS             :  'C''H''A''N''N''E''L''S'
945                         ;
946    
947    INFO                 :  'I''N''F''O'
948                         ;
949    
950    AUDIO_OUTPUT_DEVICE_COUNT :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E''_''C''O''U''N''T'
951                              ;
952    
953    AUDIO_OUTPUT_DEVICE_INFO  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E''_''I''N''F''O'
954                              ;
955    
956    MIDI_INPUT_DEVICE_COUNT   :  'M''I''D''I''_''I''N''P''U''T''_''D''E''V''I''C''E''_''C''O''U''N''T'
957                              ;
958    
959    MIDI_INPUT_DEVICE_INFO    :  'M''I''D''I''_''I''N''P''U''T''_''D''E''V''I''C''E''_''I''N''F''O'
960                              ;
961    
962    MIDI_INSTRUMENT_MAP_COUNT :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P''_''C''O''U''N''T'
963                              ;
964    
965    MIDI_INSTRUMENT_MAP_INFO  :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P''_''I''N''F''O'
966                              ;
967    
968    MIDI_INSTRUMENT_COUNT     :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''C''O''U''N''T'
969                              ;
970    
971    MIDI_INSTRUMENT_INFO      :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''I''N''F''O'
972                              ;
973    
974    DB_INSTRUMENT_DIRECTORY_COUNT :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''D''I''R''E''C''T''O''R''Y''_''C''O''U''N''T'
975                                  ;
976    
977    DB_INSTRUMENT_DIRECTORY_INFO  :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''D''I''R''E''C''T''O''R''Y''_''I''N''F''O'
978                                  ;
979    
980    DB_INSTRUMENT_COUNT           :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''C''O''U''N''T'
981                                  ;
982    
983    DB_INSTRUMENT_INFO            :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''I''N''F''O'
984                                  ;
985    
986    DB_INSTRUMENT_FILES           :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''F''I''L''E''S'
987                                  ;
988    
989    DB_INSTRUMENTS_JOB_INFO       :  'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B''_''I''N''F''O'
990                                  ;
991    
992    CHANNEL_COUNT        :  'C''H''A''N''N''E''L''_''C''O''U''N''T'
993                         ;
994    
995    CHANNEL_MIDI         :  'C''H''A''N''N''E''L''_''M''I''D''I'
996                         ;
997    
998    DEVICE_MIDI          :  'D''E''V''I''C''E''_''M''I''D''I'
999                         ;
1000    
1001    CHANNEL_INFO         :  'C''H''A''N''N''E''L''_''I''N''F''O'
1002                         ;
1003    
1004    FX_SEND_COUNT        :  'F''X''_''S''E''N''D''_''C''O''U''N''T'
1005                         ;
1006    
1007    FX_SEND_INFO         :  'F''X''_''S''E''N''D''_''I''N''F''O'
1008                         ;
1009    
1010    BUFFER_FILL          :  'B''U''F''F''E''R''_''F''I''L''L'
1011                         ;
1012    
1013    STREAM_COUNT         :  'S''T''R''E''A''M''_''C''O''U''N''T'
1014                         ;
1015    
1016    VOICE_COUNT          :  'V''O''I''C''E''_''C''O''U''N''T'
1017                         ;
1018    
1019    TOTAL_STREAM_COUNT   :  'T''O''T''A''L''_''S''T''R''E''A''M''_''C''O''U''N''T'
1020                         ;
1021    
1022    TOTAL_VOICE_COUNT    :  'T''O''T''A''L''_''V''O''I''C''E''_''C''O''U''N''T'
1023                         ;
1024    
1025    TOTAL_VOICE_COUNT_MAX:  'T''O''T''A''L''_''V''O''I''C''E''_''C''O''U''N''T''_''M''A''X'
1026                         ;
1027    
1028    GLOBAL_INFO          :  'G''L''O''B''A''L''_''I''N''F''O'
1029                         ;
1030    
1031    EFFECT_INSTANCE_COUNT   :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''_''C''O''U''N''T'
1032                            ;
1033    
1034    EFFECT_INSTANCE_INFO    :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''_''I''N''F''O'
1035                            ;
1036    
1037    SEND_EFFECT_CHAIN_COUNT :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''_''C''O''U''N''T'
1038                            ;
1039    
1040    SEND_EFFECT_CHAIN_INFO  :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''_''I''N''F''O'
1041                            ;
1042    
1043    INSTRUMENT           :  'I''N''S''T''R''U''M''E''N''T'
1044                         ;
1045    
1046    INSTRUMENTS          :  'I''N''S''T''R''U''M''E''N''T''S'
1047                         ;
1048    
1049    ENGINE               :  'E' 'N' 'G' 'I' 'N' 'E'
1050                         ;
1051    
1052    ON_DEMAND            :  'O''N''_''D''E''M''A''N''D'
1053                         ;
1054    
1055    ON_DEMAND_HOLD       :  'O''N''_''D''E''M''A''N''D''_''H''O''L''D'
1056                         ;
1057    
1058    PERSISTENT           :  'P''E''R''S''I''S''T''E''N''T'
1059                         ;
1060    
1061    AUDIO_OUTPUT_DEVICE_PARAMETER  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E''_''P''A''R''A''M''E''T''E''R'
1062                                   ;
1063    
1064    AUDIO_OUTPUT_DEVICES  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E''S'
1065                          ;
1066    
1067    AUDIO_OUTPUT_DEVICE   :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''E''V''I''C''E'
1068                          ;
1069    
1070    AUDIO_OUTPUT_DRIVER_PARAMETER  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''R''I''V''E''R''_''P''A''R''A''M''E''T''E''R'
1071                                   ;
1072    
1073    AUDIO_OUTPUT_DRIVER   :  'A''U''D''I''O''_''O''U''T''P''U''T''_''D''R''I''V''E''R'
1074                          ;
1075    
1076    AUDIO_OUTPUT_CHANNEL_PARAMETER  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''C''H''A''N''N''E''L''_''P''A''R''A''M''E''T''E''R'
1077                                    ;
1078    
1079    AUDIO_OUTPUT_CHANNEL  :  'A''U''D''I''O''_''O''U''T''P''U''T''_''C''H''A''N''N''E''L'
1080                          ;
1081    
1082    AUDIO_OUTPUT_TYPE     :  'A''U''D''I''O''_''O''U''T''P''U''T''_''T''Y''P''E'
1083                          ;
1084    
1085    AVAILABLE_EFFECTS :  'A''V''A''I''L''A''B''L''E''_''E''F''F''E''C''T''S'
1086                      ;
1087    
1088    EFFECT :  'E''F''F''E''C''T'
1089           ;
1090    
1091    EFFECT_INSTANCE :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E'
1092                    ;
1093    
1094    EFFECT_INSTANCES :  'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''S'
1095                     ;
1096    
1097    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'
1098                                  ;
1099    
1100    SEND_EFFECT_CHAIN :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N'
1101                      ;
1102    
1103    SEND_EFFECT_CHAINS :  'S''E''N''D''_''E''F''F''E''C''T''_''C''H''A''I''N''S'
1104                       ;
1105    
1106    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'
1107                                  ;
1108    
1109    MIDI_INPUT_DEVICE_PARAMETER  :  'M''I''D''I''_''I''N''P''U''T''_''D''E''V''I''C''E''_''P''A''R''A''M''E''T''E''R'
1110                                 ;
1111    
1112    MIDI_INPUT_PORT_PARAMETER    :  'M''I''D''I''_''I''N''P''U''T''_''P''O''R''T''_''P''A''R''A''M''E''T''E''R'
1113                                 ;
1114    
1115    MIDI_INPUT_DEVICES   :  'M''I''D''I''_''I''N''P''U''T''_''D''E''V''I''C''E''S'
1116                         ;
1117    
1118    MIDI_INPUT_DEVICE     :  'M''I''D''I''_''I''N''P''U''T''_''D''E''V''I''C''E'
1119                          ;
1120    
1121    MIDI_INPUT_DRIVER_PARAMETER  :  'M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R''_''P''A''R''A''M''E''T''E''R'
1122                                 ;
1123    
1124    MIDI_INSTRUMENT  :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T'
1125                     ;
1126    
1127    MIDI_INSTRUMENTS  :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''S'
1128                      ;
1129    
1130    MIDI_INSTRUMENT_MAP  :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P'
1131                         ;
1132    
1133    MIDI_INSTRUMENT_MAPS  :  'M''I''D''I''_''I''N''S''T''R''U''M''E''N''T''_''M''A''P''S'
1134                          ;
1135    
1136    MIDI_INPUT_DRIVER     :  'M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R'
1137                          ;
1138    
1139    MIDI_INPUT_PORT       :  'M''I''D''I''_''I''N''P''U''T''_''P''O''R''T'
1140                          ;
1141    
1142    MIDI_INPUT_CHANNEL    :  'M''I''D''I''_''I''N''P''U''T''_''C''H''A''N''N''E''L'
1143                          ;
1144    
1145    MIDI_INPUT_TYPE       :  'M''I''D''I''_''I''N''P''U''T''_''T''Y''P''E'
1146                          ;
1147    
1148    MIDI_INPUT            :  'M''I''D''I''_''I''N''P''U''T'
1149                          ;
1150    
1151    MIDI_INPUTS           :  'M''I''D''I''_''I''N''P''U''T''S'
1152                          ;
1153    
1154    MIDI_CONTROLLER       :  'M''I''D''I''_''C''O''N''T''R''O''L''L''E''R'
1155                          ;
1156    
1157    SEND                  :  'S''E''N''D'
1158                          ;
1159    
1160    FX_SEND               :  'F''X''_''S''E''N''D'
1161                          ;
1162    
1163    FX_SENDS              :  'F''X''_''S''E''N''D''S'
1164                          ;
1165    
1166    DB_INSTRUMENT_DIRECTORY    :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''D''I''R''E''C''T''O''R''Y'
1167                               ;
1168    
1169    DB_INSTRUMENT_DIRECTORIES  :  'D''B''_''I''N''S''T''R''U''M''E''N''T''_''D''I''R''E''C''T''O''R''I''E''S'
1170                               ;
1171    
1172    DB_INSTRUMENTS             :  'D''B''_''I''N''S''T''R''U''M''E''N''T''S'
1173                               ;
1174    
1175    DB_INSTRUMENT              :  'D''B''_''I''N''S''T''R''U''M''E''N''T'
1176                               ;
1177    
1178    DB_INSTRUMENTS_JOB         :  'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B'
1179                               ;
1180    
1181    INSTRUMENTS_DB             :  'I''N''S''T''R''U''M''E''N''T''S''_''D''B'
1182                               ;
1183    
1184    DESCRIPTION                :  'D''E''S''C''R''I''P''T''I''O''N'
1185                               ;
1186    
1187    FORCE                      :  'F''O''R''C''E'
1188                               ;
1189    
1190    FLAT                       :  'F''L''A''T'
1191                               ;
1192    
1193    RECURSIVE                  :  'R''E''C''U''R''S''I''V''E'
1194                               ;
1195    
1196    NON_RECURSIVE              :  'N''O''N''_''R''E''C''U''R''S''I''V''E'
1197                               ;
1198    
1199    LOST                       :  'L''O''S''T'
1200                               ;
1201    
1202    FILE_PATH                  :  'F''I''L''E''_''P''A''T''H'
1203                               ;
1204    
1205    SERVER                :  'S''E''R''V''E''R'
1206                          ;
1207    
1208    VOLUME                :  'V''O''L''U''M''E'
1209                          ;
1210    
1211    LEVEL                 :  'L''E''V''E''L'
1212                          ;
1213    
1214    VALUE                 :  'V''A''L''U''E'
1215                          ;
1216    
1217    MUTE                  :  'M''U''T''E'
1218                          ;
1219    
1220    SOLO                  :  'S''O''L''O'
1221                          ;
1222    
1223    VOICES                :  'V''O''I''C''E''S'
1224                          ;
1225    
1226    STREAMS               :  'S''T''R''E''A''M''S'
1227                          ;
1228    
1229    BYTES                 :  'B''Y''T''E''S'
1230                          ;
1231    
1232    PERCENTAGE            :  'P''E''R''C''E''N''T''A''G''E'
1233                          ;
1234    
1235    FILE                  :  'F''I''L''E'
1236                          ;
1237    
1238    EDIT                  :  'E''D''I''T'
1239                          ;
1240    
1241    FORMAT                :  'F''O''R''M''A''T'
1242                          ;
1243    
1244    MIDI_DATA             :  'M''I''D''I''_''D''A''T''A'
1245                          ;
1246    
1247    RESET                 :  'R''E''S''E''T'
1248                          ;
1249    
1250    MISCELLANEOUS         :  'M''I''S''C''E''L''L''A''N''E''O''U''S'
1251                          ;
1252    
1253    NAME                  :  'N''A''M''E'
1254                          ;
1255    
1256    ECHO                  :  'E''C''H''O'
1257                          ;
1258    
1259    QUIT                  :  'Q''U''I''T'
1260                        ;                        ;
1261    
1262  %%  %%
1263    
1264    #define DEBUG_BISON_SYNTAX_ERROR_WALKER 0
1265    
1266  /**  /**
1267   * Will be called when an error occured (usually syntax error).   * Internal function, only called by yyExpectedSymbols(). It is given a Bison
1268     * parser state stack, reflecting the parser's entire state at a certain point,
1269     * i.e. when a syntax error occured. This function will then walk ahead the
1270     * potential parse tree starting from the current head of the given state
1271     * stack. This function will call itself recursively to scan the individual
1272     * parse tree branches. As soon as it hits on the next non-terminal grammar
1273     * symbol in one parse tree branch, it adds the found non-terminal symbol to
1274     * @a expectedSymbols and aborts scanning the respective tree branch further.
1275     * If any local parser state is reached a second time, the respective parse
1276     * tree is aborted to avoid any endless recursion.
1277     *
1278     * @param stack - Bison (yacc) state stack
1279     * @param expectedSymbols - will be filled with next expected grammar symbols
1280     * @param depth - just for internal debugging purposes
1281   */   */
1282  void yyerror(const char* s) {  static void walkAndFillExpectedSymbols(std::vector<YYTYPE_INT16>& stack, std::set<String>& expectedSymbols, int depth = 0) {
1283      dmsg(2,("LSCPParser: %s\n", s));  #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1284        printf("\n");
1285        for (int i = 0; i < depth; ++i) printf("\t");
1286        printf("State stack:");
1287        for (int i = 0; i < stack.size(); ++i) {
1288            printf(" %d", stack[i]);
1289        }
1290        printf("\n");
1291    #endif
1292    
1293        if (stack.empty()) return;
1294    
1295        int state = stack[stack.size() - 1];
1296        int n = yypact[state];
1297        if (n == YYPACT_NINF) { // default reduction required ...
1298            // get default reduction rule for this state
1299            n = yydefact[state];
1300            if (n <= 0 || n >= YYNRULES) return; // no rule, something is wrong
1301            // return the new resolved expected symbol (left-hand symbol of grammar
1302            // rule), then we're done in this state
1303            expectedSymbols.insert(yytname[yyr1[n]]);
1304            return;
1305        }
1306        if (!(YYPACT_NINF < n && n <= YYLAST)) return;
1307    
1308    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1309        for (int i = 0; i < depth; ++i) printf("\t");
1310        printf("Expected tokens:");
1311    #endif
1312        int begin = n < 0 ? -n : 0;
1313        int checklim = YYLAST - n + 1;
1314        int end = checklim < YYNTOKENS ? checklim : YYNTOKENS;
1315        int rule, action, stackSize;
1316        for (int token = begin; token < end; ++token) {
1317            if (token == YYTERROR || yycheck[n + token] != token) continue;
1318    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1319            printf(" %s", yytname[token]);
1320    #endif
1321    
1322            //if (yycheck[n + token] != token) goto default_reduction;
1323    
1324            action = yytable[n + token];
1325            if (action == 0 || action == YYTABLE_NINF) {
1326    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1327                printf(" (invalid action) "); fflush(stdout);
1328    #endif
1329                continue; // error, ignore
1330            }
1331            if (action < 0) { // reduction with rule -action required ...
1332    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1333                printf(" (reduction) "); fflush(stdout);
1334    #endif
1335                rule = -action;
1336                goto reduce;
1337            }
1338            if (action == YYFINAL) continue; // "accept" state, we don't care about it here
1339    
1340            // "shift" required ...
1341    
1342            if (std::find(stack.begin(), stack.end(), action) != stack.end())
1343                continue; // duplicate state, ignore it to avoid endless recursions
1344    
1345            // "shift" / push the new state on the state stack and call this
1346            // function recursively, and restore the stack after the recurse return
1347            stackSize = stack.size();
1348            stack.push_back(action);
1349            walkAndFillExpectedSymbols( //FIXME: could cause stack overflow (should be a loop instead), is probably fine with our current grammar though
1350                stack, expectedSymbols, depth + 1
1351            );
1352            stack.resize(stackSize); // restore stack
1353            continue;
1354    
1355        //default_reduction: // resolve default reduction for this state
1356        //    printf(" (default red.) "); fflush(stdout);
1357        //    rule = yydefact[state];
1358    
1359        reduce: // "reduce" required
1360    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1361            printf(" (reduce by %d) ", rule); fflush(stdout);
1362    #endif
1363            if (rule == 0 || rule >= YYNRULES) continue; // invalid rule, something is wrong
1364            // store the left-hand symbol of the grammar rule
1365            expectedSymbols.insert(yytname[yyr1[rule]]);
1366    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1367            printf(" (SYM %s) ", yytname[yyr1[rule]]); fflush(stdout);
1368    #endif
1369        }
1370    #if DEBUG_BISON_SYNTAX_ERROR_WALKER
1371        printf("\n");
1372    #endif
1373  }  }
1374    
1375  /**  /**
1376   * Clears input buffer and restarts scanner.   * Should only be called on syntax errors: returns a set of non-terminal
1377     * symbols expected to appear now/next, just at the point where the syntax
1378     * error appeared.
1379     */
1380    static std::set<String> yyExpectedSymbols() {
1381        std::set<String> result;
1382        yyparse_param_t* param = GetCurrentYaccSession();
1383        YYTYPE_INT16* ss = (*param->ppStackBottom);
1384        YYTYPE_INT16* sp = (*param->ppStackTop);
1385        int iStackSize   = sp - ss + 1;
1386        // copy and wrap parser's state stack into a convenient STL container
1387        std::vector<YYTYPE_INT16> stack;
1388        for (int i = 0; i < iStackSize; ++i) {
1389            stack.push_back(ss[i]);
1390        }
1391        // do the actual parser work
1392        walkAndFillExpectedSymbols(stack, result);
1393        return result;
1394    }
1395    
1396    namespace LinuxSampler {
1397    
1398    /**
1399     * Clears input buffer.
1400   */   */
1401  void restart(yyparse_param_t* pparam, int& yychar) {  void restart(yyparse_param_t* pparam, int& yychar) {
1402      // restart scanner      bytes = 0;
1403      yyrestart(stdin, pparam->pScanner);      ptr   = 0;
1404      // reset lookahead symbol      sLastError = "";
1405      yyclearin;      sParsed = "";
1406    }
1407    
1408  }  }

Legend:
Removed from v.210  
changed lines
  Added in v.2510

  ViewVC Help
Powered by ViewVC