--- linuxsampler/trunk/src/network/lscp.y 2007/05/29 23:59:36 1212 +++ linuxsampler/trunk/src/network/lscp.y 2010/09/30 20:00:43 2135 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005 - 2007 Christian Schoenebeck * + * Copyright (C) 2005 - 2010 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -21,37 +21,52 @@ * MA 02111-1307 USA * ***************************************************************************/ -/* CAUTION: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -/* */ -/* don't forget to run 'make parser' after you changed this file, */ -/* otherwise the parser will not be regenerated ! */ -/* */ -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ +/* + The parser's C++ source files should be automatically (re)generated if + this file was modified. If not, or in case you want explicitly + regenerate the parser C++ files, run 'make parser'. In both cases you + need to have bison or another yacc compatible parser generator + installed though. +*/ %{ #include "lscpparser.h" #include "lscpserver.h" #include "lscpevent.h" +#include "lscpsymbols.h" + +namespace LinuxSampler { // to save us typing work in the rules action definitions #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer +#define SESSION_PARAM ((yyparse_param_t*) yyparse_param) +#define INCREMENT_LINE { SESSION_PARAM->iLine++; SESSION_PARAM->iColumn = 0; } // clears input buffer void restart(yyparse_param_t* pparam, int& yychar); #define RESTART restart((yyparse_param_t*) YYPARSE_PARAM, yychar) -// we provide our own version of yyerror() so we don't have to link against the yacc library -void yyerror(const char* s); - static char buf[1024]; // input buffer to feed the parser with new characters static int bytes = 0; // current number of characters in the input buffer static int ptr = 0; // current position in the input buffer +static String sLastError; // error message of the last error occured // external reference to the function which actually reads from the socket extern int GetLSCPCommand( void *buf, int max_size); +// external reference to the function in lscpserver.cpp which returns the +// current session (only works because the server runs as singleton) +extern yyparse_param_t* GetCurrentYaccSession(); + +// returns true if supplied characters has an ASCII code of 128 or higher +inline bool isExtendedAsciiChar(const char c) { + return (c < 0); +} + // custom scanner function which reads from the socket +// (bison expects it to return the numerical ID of the next +// "recognized token" from the input stream) int yylex(YYSTYPE* yylval) { // check if we have to read new characters if (ptr >= bytes) { @@ -62,22 +77,56 @@ return 0; } } - return (int) buf[ptr++]; + // this is the next character in the input stream + const char c = buf[ptr++]; + // increment current reading position (just for verbosity / messages) + GetCurrentYaccSession()->iColumn++; + // we have to handle "normal" and "extended" ASCII characters separately + if (isExtendedAsciiChar(c)) { + // workaround for characters with ASCII code higher than 127 + yylval->Char = c; + return EXT_ASCII_CHAR; + } else { + // simply return the ASCII code as terminal symbol ID + return (int) c; + } } +// parser helper functions + +int octalsToNumber(char oct_digit0, char oct_digit1 = '0', char oct_digit2 = '0') { + const char d0[] = { oct_digit0, '\0' }; + const char d1[] = { oct_digit1, '\0' }; + const char d2[] = { oct_digit2, '\0' }; + return atoi(d2)*8*8 + atoi(d1)*8 + atoi(d0); +} + +} + +// we provide our own version of yyerror() so we don't have to link against the yacc library +void yyerror(const char* s); + +using namespace LinuxSampler; + %} // reentrant parser %pure_parser -%type char digit -%type dotnum volume_value boolean +// tell bison to spit out verbose syntax error messages +%error-verbose + +%token EXT_ASCII_CHAR + +%type char char_base alpha_char digit digit_oct digit_hex escape_seq escape_seq_octal escape_seq_hex +%type real dotnum volume_value boolean effect_control_value %type number sampler_channel instrument_index fx_send_id audio_channel_index device_index midi_input_channel_index midi_input_port_index midi_map midi_bank midi_prog midi_ctrl -%type string text stringval digits param_val_list param_val query_val pathname dirname filename map_name entry_name fx_send_name engine_name command add_instruction create_instruction destroy_instruction get_instruction list_instruction load_instruction set_chan_instruction load_instr_args load_engine_args audio_output_type_name midi_input_type_name remove_instruction unmap_instruction set_instruction subscribe_event unsubscribe_event map_instruction reset_instruction clear_instruction find_instruction move_instruction copy_instruction scan_mode edit_instruction +%type string string_escaped text text_escaped text_escaped_base stringval stringval_escaped digits param_val_list param_val query_val filename db_path map_name entry_name fx_send_name 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 %type buffer_size_type %type key_val_list query_val_list %type instr_load_mode %type modal_arg +%type path path_base path_prefix path_body %start input @@ -98,10 +147,10 @@ | line CR LF ; -line : /* epsilon (empty line ignored) */ { return LSCP_DONE; } - | comment { return LSCP_DONE; } - | command { LSCPSERVER->AnswerClient($1); return LSCP_DONE; } - | error { LSCPSERVER->AnswerClient("ERR:0:Unknown command.\r\n"); RESTART; return LSCP_SYNTAX_ERROR; } +line : /* epsilon (empty line ignored) */ { INCREMENT_LINE; return LSCP_DONE; } + | comment { INCREMENT_LINE; return LSCP_DONE; } + | command { INCREMENT_LINE; LSCPSERVER->AnswerClient($1); return LSCP_DONE; } + | error { INCREMENT_LINE; LSCPSERVER->AnswerClient("ERR:0:" + sLastError + "\r\n"); RESTART; return LSCP_SYNTAX_ERROR; } ; comment : '#' @@ -129,20 +178,27 @@ | MOVE SP move_instruction { $$ = $3; } | COPY SP copy_instruction { $$ = $3; } | EDIT SP edit_instruction { $$ = $3; } + | FORMAT SP format_instruction { $$ = $3; } + | SEND SP send_instruction { $$ = $3; } + | APPEND SP append_instruction { $$ = $3; } + | INSERT SP insert_instruction { $$ = $3; } | RESET { $$ = LSCPSERVER->ResetSampler(); } | QUIT { LSCPSERVER->AnswerClient("Bye!\r\n"); return LSCP_QUIT; } ; -add_instruction : CHANNEL { $$ = LSCPSERVER->AddChannel(); } - | DB_INSTRUMENT_DIRECTORY SP pathname { $$ = LSCPSERVER->AddDbInstrumentDirectory($3); } - | DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP pathname SP pathname { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true); } - | DB_INSTRUMENTS SP scan_mode SP pathname SP pathname { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7); } - | DB_INSTRUMENTS SP NON_MODAL SP pathname SP pathname { $$ = LSCPSERVER->AddDbInstruments($5,$7, -1, true); } - | DB_INSTRUMENTS SP NON_MODAL SP pathname SP pathname SP instrument_index { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true); } - | DB_INSTRUMENTS SP pathname SP pathname { $$ = LSCPSERVER->AddDbInstruments($3,$5); } - | DB_INSTRUMENTS SP pathname SP pathname SP instrument_index { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7); } +add_instruction : CHANNEL { $$ = LSCPSERVER->AddChannel(); } + | DB_INSTRUMENT_DIRECTORY SP db_path { $$ = LSCPSERVER->AddDbInstrumentDirectory($3); } + | DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true); } + | DB_INSTRUMENTS SP NON_MODAL SP scan_mode SP FILE_AS_DIR SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($5,$9,$11, true, true); } + | DB_INSTRUMENTS SP scan_mode SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7); } + | DB_INSTRUMENTS SP scan_mode SP FILE_AS_DIR SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($3,$7,$9, false, true); } + | DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($5,$7, -1, true); } + | DB_INSTRUMENTS SP NON_MODAL SP db_path SP filename SP instrument_index { $$ = LSCPSERVER->AddDbInstruments($5,$7,$9, true); } + | DB_INSTRUMENTS SP db_path SP filename { $$ = LSCPSERVER->AddDbInstruments($3,$5); } + | DB_INSTRUMENTS SP db_path SP filename SP instrument_index { $$ = LSCPSERVER->AddDbInstruments($3,$5,$7); } | MIDI_INSTRUMENT_MAP { $$ = LSCPSERVER->AddMidiInstrumentMap(); } | MIDI_INSTRUMENT_MAP SP map_name { $$ = LSCPSERVER->AddMidiInstrumentMap($3); } + | MASTER_EFFECT_CHAIN SP number { $$ = LSCPSERVER->AddMasterEffectChain($3); } ; subscribe_event : AUDIO_OUTPUT_DEVICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_audio_device_count); } @@ -150,6 +206,8 @@ | MIDI_INPUT_DEVICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_device_count); } | MIDI_INPUT_DEVICE_INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_midi_device_info); } | CHANNEL_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_count); } + | CHANNEL_MIDI { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_channel_midi); } + | DEVICE_MIDI { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_device_midi); } | VOICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_voice_count); } | STREAM_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_stream_count); } | BUFFER_FILL { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_buffer_fill); } @@ -166,6 +224,7 @@ | DB_INSTRUMENT_INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instr_info); } | DB_INSTRUMENTS_JOB_INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_db_instrs_job_info); } | MISCELLANEOUS { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_misc); } + | TOTAL_STREAM_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_stream_count); } | TOTAL_VOICE_COUNT { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_total_voice_count); } | GLOBAL_INFO { $$ = LSCPSERVER->SubscribeNotification(LSCPEvent::event_global_info); } ; @@ -175,6 +234,8 @@ | MIDI_INPUT_DEVICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_device_count); } | MIDI_INPUT_DEVICE_INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_midi_device_info); } | CHANNEL_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_count); } + | CHANNEL_MIDI { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_channel_midi); } + | DEVICE_MIDI { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_device_midi); } | VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_voice_count); } | STREAM_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_stream_count); } | BUFFER_FILL { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_buffer_fill); } @@ -191,28 +252,38 @@ | DB_INSTRUMENT_INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instr_info); } | DB_INSTRUMENTS_JOB_INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_db_instrs_job_info); } | MISCELLANEOUS { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_misc); } + | TOTAL_STREAM_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_stream_count); } | TOTAL_VOICE_COUNT { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_total_voice_count); } | GLOBAL_INFO { $$ = LSCPSERVER->UnsubscribeNotification(LSCPEvent::event_global_info); } ; -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::VOID,"",$3); } +map_instruction : MIDI_INSTRUMENT SP modal_arg midi_map SP midi_bank SP midi_prog SP engine_name SP filename SP instrument_index SP volume_value { $$ = LSCPSERVER->AddOrReplaceMIDIInstrumentMapping($4,$6,$8,$10,$12,$14,$16,MidiInstrumentMapper::DONTCARE,"",$3); } | 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); } - | 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::VOID,$18,$3); } + | 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); } | 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); } ; unmap_instruction : MIDI_INSTRUMENT SP midi_map SP midi_bank SP midi_prog { $$ = LSCPSERVER->RemoveMIDIInstrumentMapping($3,$5,$7); } ; -remove_instruction : CHANNEL SP sampler_channel { $$ = LSCPSERVER->RemoveChannel($3); } - | MIDI_INSTRUMENT_MAP SP midi_map { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3); } - | MIDI_INSTRUMENT_MAP SP ALL { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps(); } - | DB_INSTRUMENT_DIRECTORY SP FORCE SP pathname { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($5, true); } - | DB_INSTRUMENT_DIRECTORY SP pathname { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($3); } - | DB_INSTRUMENT SP pathname { $$ = LSCPSERVER->RemoveDbInstrument($3); } +remove_instruction : CHANNEL SP sampler_channel { $$ = LSCPSERVER->RemoveChannel($3); } + | MIDI_INSTRUMENT_MAP SP midi_map { $$ = LSCPSERVER->RemoveMidiInstrumentMap($3); } + | MIDI_INSTRUMENT_MAP SP ALL { $$ = LSCPSERVER->RemoveAllMidiInstrumentMaps(); } + | MASTER_EFFECT_CHAIN SP number SP number { $$ = LSCPSERVER->RemoveMasterEffectChain($3,$5); } + | MASTER_EFFECT_CHAIN SP EFFECT SP number SP number SP number { $$ = LSCPSERVER->RemoveMasterEffectChainEffect($5,$7,$9); } + | DB_INSTRUMENT_DIRECTORY SP FORCE SP db_path { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($5, true); } + | DB_INSTRUMENT_DIRECTORY SP db_path { $$ = LSCPSERVER->RemoveDbInstrumentDirectory($3); } + | DB_INSTRUMENT SP db_path { $$ = LSCPSERVER->RemoveDbInstrument($3); } ; get_instruction : AVAILABLE_ENGINES { $$ = LSCPSERVER->GetAvailableEngines(); } + | AVAILABLE_EFFECTS { $$ = LSCPSERVER->GetAvailableEffects(); } + | EFFECT_INSTANCES { $$ = LSCPSERVER->GetEffectInstances(); } + | EFFECT SP INFO SP number { $$ = LSCPSERVER->GetEffectInfo($5); } + | EFFECT_INSTANCE SP INFO SP number { $$ = LSCPSERVER->GetEffectInstanceInfo($5); } + | EFFECT_INSTANCE_INPUT_CONTROL SP INFO SP number SP number { $$ = LSCPSERVER->GetEffectInstanceInputControlInfo($5,$7); } + | MASTER_EFFECT_CHAINS SP number { $$ = LSCPSERVER->GetMasterEffectChains($3); } + | MASTER_EFFECT_CHAIN SP INFO SP number SP number { $$ = LSCPSERVER->GetMasterEffectChainInfo($5,$7); } | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->GetAvailableMidiInputDrivers(); } | MIDI_INPUT_DRIVER SP INFO SP string { $$ = LSCPSERVER->GetMidiInputDriverInfo($5); } | MIDI_INPUT_DRIVER_PARAMETER SP INFO SP string SP string { $$ = LSCPSERVER->GetMidiInputDriverParameterInfo($5, $7); } @@ -236,6 +307,7 @@ | CHANNEL SP VOICE_COUNT SP sampler_channel { $$ = LSCPSERVER->GetVoiceCount($5); } | ENGINE SP INFO SP engine_name { $$ = LSCPSERVER->GetEngineInfo($5); } | SERVER SP INFO { $$ = LSCPSERVER->GetServerInfo(); } + | TOTAL_STREAM_COUNT { $$ = LSCPSERVER->GetTotalStreamCount(); } | TOTAL_VOICE_COUNT { $$ = LSCPSERVER->GetTotalVoiceCount(); } | TOTAL_VOICE_COUNT_MAX { $$ = LSCPSERVER->GetTotalVoiceCountMax(); } | MIDI_INSTRUMENTS SP midi_map { $$ = LSCPSERVER->GetMidiInstrumentMappings($3); } @@ -245,32 +317,41 @@ | MIDI_INSTRUMENT_MAP SP INFO SP midi_map { $$ = LSCPSERVER->GetMidiInstrumentMap($5); } | FX_SENDS SP sampler_channel { $$ = LSCPSERVER->GetFxSends($3); } | FX_SEND SP INFO SP sampler_channel SP fx_send_id { $$ = LSCPSERVER->GetFxSendInfo($5,$7); } - | DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP pathname { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($5, true); } - | DB_INSTRUMENT_DIRECTORIES SP pathname { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($3, false); } - | DB_INSTRUMENT_DIRECTORY SP INFO SP pathname { $$ = LSCPSERVER->GetDbInstrumentDirectoryInfo($5); } - | DB_INSTRUMENTS SP RECURSIVE SP pathname { $$ = LSCPSERVER->GetDbInstrumentCount($5, true); } - | DB_INSTRUMENTS SP pathname { $$ = LSCPSERVER->GetDbInstrumentCount($3, false); } - | DB_INSTRUMENT SP INFO SP pathname { $$ = LSCPSERVER->GetDbInstrumentInfo($5); } + | DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP db_path { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($5, true); } + | DB_INSTRUMENT_DIRECTORIES SP db_path { $$ = LSCPSERVER->GetDbInstrumentDirectoryCount($3, false); } + | DB_INSTRUMENT_DIRECTORY SP INFO SP db_path { $$ = LSCPSERVER->GetDbInstrumentDirectoryInfo($5); } + | DB_INSTRUMENTS SP RECURSIVE SP db_path { $$ = LSCPSERVER->GetDbInstrumentCount($5, true); } + | DB_INSTRUMENTS SP db_path { $$ = LSCPSERVER->GetDbInstrumentCount($3, false); } + | DB_INSTRUMENT SP INFO SP db_path { $$ = LSCPSERVER->GetDbInstrumentInfo($5); } | DB_INSTRUMENTS_JOB SP INFO SP number { $$ = LSCPSERVER->GetDbInstrumentsJobInfo($5); } | VOLUME { $$ = LSCPSERVER->GetGlobalVolume(); } + | VOICES { $$ = LSCPSERVER->GetGlobalMaxVoices(); } + | STREAMS { $$ = LSCPSERVER->GetGlobalMaxStreams(); } + | FILE SP INSTRUMENTS SP filename { $$ = LSCPSERVER->GetFileInstruments($5); } + | FILE SP INSTRUMENT SP INFO SP filename SP instrument_index { $$ = LSCPSERVER->GetFileInstrumentInfo($7,$9); } ; set_instruction : AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7); } | AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); } | MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7); } + | MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' NONE { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, ""); } | MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9); } + | EFFECT_INSTANCE_INPUT_CONTROL SP number SP number SP effect_control_value { $$ = LSCPSERVER->SetEffectInstanceInputControl($3, $5, $7); } | CHANNEL SP set_chan_instruction { $$ = $3; } | MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7); } | FX_SEND SP NAME SP sampler_channel SP fx_send_id SP fx_send_name { $$ = LSCPSERVER->SetFxSendName($5,$7,$9); } | FX_SEND SP AUDIO_OUTPUT_CHANNEL SP sampler_channel SP fx_send_id SP audio_channel_index SP audio_channel_index { $$ = LSCPSERVER->SetFxSendAudioOutputChannel($5,$7,$9,$11); } | FX_SEND SP MIDI_CONTROLLER SP sampler_channel SP fx_send_id SP midi_ctrl { $$ = LSCPSERVER->SetFxSendMidiController($5,$7,$9); } | FX_SEND SP LEVEL SP sampler_channel SP fx_send_id SP volume_value { $$ = LSCPSERVER->SetFxSendLevel($5,$7,$9); } - | DB_INSTRUMENT_DIRECTORY SP NAME SP pathname SP dirname { $$ = LSCPSERVER->SetDbInstrumentDirectoryName($5,$7); } - | DB_INSTRUMENT_DIRECTORY SP DESCRIPTION SP pathname SP stringval { $$ = LSCPSERVER->SetDbInstrumentDirectoryDescription($5,$7); } - | DB_INSTRUMENT SP NAME SP pathname SP dirname { $$ = LSCPSERVER->SetDbInstrumentName($5,$7); } - | DB_INSTRUMENT SP DESCRIPTION SP pathname SP stringval { $$ = LSCPSERVER->SetDbInstrumentDescription($5,$7); } + | DB_INSTRUMENT_DIRECTORY SP NAME SP db_path SP stringval_escaped { $$ = LSCPSERVER->SetDbInstrumentDirectoryName($5,$7); } + | DB_INSTRUMENT_DIRECTORY SP DESCRIPTION SP db_path SP stringval_escaped { $$ = LSCPSERVER->SetDbInstrumentDirectoryDescription($5,$7); } + | DB_INSTRUMENT SP NAME SP db_path SP stringval_escaped { $$ = LSCPSERVER->SetDbInstrumentName($5,$7); } + | DB_INSTRUMENT SP DESCRIPTION SP db_path SP stringval_escaped { $$ = LSCPSERVER->SetDbInstrumentDescription($5,$7); } + | DB_INSTRUMENT SP FILE_PATH SP filename SP filename { $$ = LSCPSERVER->SetDbInstrumentFilePath($5,$7); } | ECHO SP boolean { $$ = LSCPSERVER->SetEcho((yyparse_param_t*) yyparse_param, $3); } | VOLUME SP volume_value { $$ = LSCPSERVER->SetGlobalVolume($3); } + | VOICES SP number { $$ = LSCPSERVER->SetGlobalMaxVoices($3); } + | STREAMS SP number { $$ = LSCPSERVER->SetGlobalMaxStreams($3); } ; create_instruction : AUDIO_OUTPUT_DEVICE SP string SP key_val_list { $$ = LSCPSERVER->CreateAudioOutputDevice($3,$5); } @@ -279,6 +360,8 @@ | MIDI_INPUT_DEVICE SP string { $$ = LSCPSERVER->CreateMidiInputDevice($3); } | FX_SEND SP sampler_channel SP midi_ctrl { $$ = LSCPSERVER->CreateFxSend($3,$5); } | FX_SEND SP sampler_channel SP midi_ctrl SP fx_send_name { $$ = LSCPSERVER->CreateFxSend($3,$5,$7); } + | EFFECT_INSTANCE SP number { $$ = LSCPSERVER->CreateEffectInstance($3); } + | EFFECT_INSTANCE SP string SP filename SP effect_name { $$ = LSCPSERVER->CreateEffectInstance($3,$5,$7); } ; reset_instruction : CHANNEL SP sampler_channel { $$ = LSCPSERVER->ResetChannel($3); } @@ -288,29 +371,37 @@ | MIDI_INSTRUMENTS SP ALL { $$ = LSCPSERVER->ClearAllMidiInstrumentMappings(); } ; -find_instruction : DB_INSTRUMENTS SP NON_RECURSIVE SP pathname SP query_val_list { $$ = LSCPSERVER->FindDbInstruments($5,$7, false); } - | DB_INSTRUMENTS SP pathname SP query_val_list { $$ = LSCPSERVER->FindDbInstruments($3,$5, true); } - | DB_INSTRUMENT_DIRECTORIES SP NON_RECURSIVE SP pathname SP query_val_list { $$ = LSCPSERVER->FindDbInstrumentDirectories($5,$7, false); } - | DB_INSTRUMENT_DIRECTORIES SP pathname SP query_val_list { $$ = LSCPSERVER->FindDbInstrumentDirectories($3,$5, true); } +find_instruction : DB_INSTRUMENTS SP NON_RECURSIVE SP db_path SP query_val_list { $$ = LSCPSERVER->FindDbInstruments($5,$7, false); } + | DB_INSTRUMENTS SP db_path SP query_val_list { $$ = LSCPSERVER->FindDbInstruments($3,$5, true); } + | DB_INSTRUMENT_DIRECTORIES SP NON_RECURSIVE SP db_path SP query_val_list { $$ = LSCPSERVER->FindDbInstrumentDirectories($5,$7, false); } + | DB_INSTRUMENT_DIRECTORIES SP db_path SP query_val_list { $$ = LSCPSERVER->FindDbInstrumentDirectories($3,$5, true); } + | LOST SP DB_INSTRUMENT_FILES { $$ = LSCPSERVER->FindLostDbInstrumentFiles(); } ; -move_instruction : DB_INSTRUMENT_DIRECTORY SP pathname SP pathname { $$ = LSCPSERVER->MoveDbInstrumentDirectory($3,$5); } - | DB_INSTRUMENT SP pathname SP pathname { $$ = LSCPSERVER->MoveDbInstrument($3,$5); } +move_instruction : DB_INSTRUMENT_DIRECTORY SP db_path SP db_path { $$ = LSCPSERVER->MoveDbInstrumentDirectory($3,$5); } + | DB_INSTRUMENT SP db_path SP db_path { $$ = LSCPSERVER->MoveDbInstrument($3,$5); } ; -copy_instruction : DB_INSTRUMENT_DIRECTORY SP pathname SP pathname { $$ = LSCPSERVER->CopyDbInstrumentDirectory($3,$5); } - | DB_INSTRUMENT SP pathname SP pathname { $$ = LSCPSERVER->CopyDbInstrument($3,$5); } +copy_instruction : DB_INSTRUMENT_DIRECTORY SP db_path SP db_path { $$ = LSCPSERVER->CopyDbInstrumentDirectory($3,$5); } + | DB_INSTRUMENT SP db_path SP db_path { $$ = LSCPSERVER->CopyDbInstrument($3,$5); } ; destroy_instruction : AUDIO_OUTPUT_DEVICE SP number { $$ = LSCPSERVER->DestroyAudioOutputDevice($3); } | MIDI_INPUT_DEVICE SP number { $$ = LSCPSERVER->DestroyMidiInputDevice($3); } | FX_SEND SP sampler_channel SP fx_send_id { $$ = LSCPSERVER->DestroyFxSend($3,$5); } + | EFFECT_INSTANCE SP number { $$ = LSCPSERVER->DestroyEffectInstance($3); } ; load_instruction : INSTRUMENT SP load_instr_args { $$ = $3; } | ENGINE SP load_engine_args { $$ = $3; } ; +append_instruction : MASTER_EFFECT_CHAIN SP EFFECT SP number SP number SP number { $$ = LSCPSERVER->AppendMasterEffectChainEffect($5,$7,$9); } + ; + +insert_instruction : MASTER_EFFECT_CHAIN SP EFFECT SP number SP number SP number SP number { $$ = LSCPSERVER->InsertMasterEffectChainEffect($5,$7,$9,$11); } + ; + set_chan_instruction : AUDIO_OUTPUT_DEVICE SP sampler_channel SP device_index { $$ = LSCPSERVER->SetAudioOutputDevice($5, $3); } | AUDIO_OUTPUT_CHANNEL SP sampler_channel SP audio_channel_index SP audio_channel_index { $$ = LSCPSERVER->SetAudioOutputChannel($5, $7, $3); } | AUDIO_OUTPUT_TYPE SP sampler_channel SP audio_output_type_name { $$ = LSCPSERVER->SetAudioOutputType($5, $3); } @@ -327,7 +418,10 @@ | MIDI_INSTRUMENT_MAP SP sampler_channel SP DEFAULT { $$ = LSCPSERVER->SetChannelMap($3, -2); } ; -edit_instruction : INSTRUMENT SP sampler_channel { $$ = LSCPSERVER->EditSamplerChannelInstrument($3); } +edit_instruction : CHANNEL SP INSTRUMENT SP sampler_channel { $$ = LSCPSERVER->EditSamplerChannelInstrument($5); } + ; + +format_instruction : INSTRUMENTS_DB { $$ = LSCPSERVER->FormatInstrumentsDb(); } ; modal_arg : /* epsilon (empty argument) */ { $$ = true; } @@ -346,16 +440,23 @@ | MIDI_INPUT_DEVICES { $$ = LSCPSERVER->GetMidiInputDevices(); } | CHANNELS { $$ = LSCPSERVER->ListChannels(); } | AVAILABLE_ENGINES { $$ = LSCPSERVER->ListAvailableEngines(); } + | AVAILABLE_EFFECTS { $$ = LSCPSERVER->ListAvailableEffects(); } + | EFFECT_INSTANCES { $$ = LSCPSERVER->ListEffectInstances(); } + | MASTER_EFFECT_CHAINS SP number { $$ = LSCPSERVER->ListMasterEffectChains($3); } | AVAILABLE_MIDI_INPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableMidiInputDrivers(); } | AVAILABLE_AUDIO_OUTPUT_DRIVERS { $$ = LSCPSERVER->ListAvailableAudioOutputDrivers(); } | MIDI_INSTRUMENTS SP midi_map { $$ = LSCPSERVER->ListMidiInstrumentMappings($3); } | MIDI_INSTRUMENTS SP ALL { $$ = LSCPSERVER->ListAllMidiInstrumentMappings(); } | MIDI_INSTRUMENT_MAPS { $$ = LSCPSERVER->ListMidiInstrumentMaps(); } | FX_SENDS SP sampler_channel { $$ = LSCPSERVER->ListFxSends($3); } - | DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP pathname { $$ = LSCPSERVER->GetDbInstrumentDirectories($5, true); } - | DB_INSTRUMENT_DIRECTORIES SP pathname { $$ = LSCPSERVER->GetDbInstrumentDirectories($3); } - | DB_INSTRUMENTS SP RECURSIVE SP pathname { $$ = LSCPSERVER->GetDbInstruments($5, true); } - | DB_INSTRUMENTS SP pathname { $$ = LSCPSERVER->GetDbInstruments($3); } + | DB_INSTRUMENT_DIRECTORIES SP RECURSIVE SP db_path { $$ = LSCPSERVER->GetDbInstrumentDirectories($5, true); } + | DB_INSTRUMENT_DIRECTORIES SP db_path { $$ = LSCPSERVER->GetDbInstrumentDirectories($3); } + | DB_INSTRUMENTS SP RECURSIVE SP db_path { $$ = LSCPSERVER->GetDbInstruments($5, true); } + | DB_INSTRUMENTS SP db_path { $$ = LSCPSERVER->GetDbInstruments($3); } + | FILE SP INSTRUMENTS SP filename { $$ = LSCPSERVER->ListFileInstruments($5); } + ; + +send_instruction : CHANNEL SP MIDI_DATA SP string SP sampler_channel SP number SP number { $$ = LSCPSERVER->SendChannelMidiData($5, $7, $9, $11); } ; load_instr_args : filename SP instrument_index SP sampler_channel { $$ = LSCPSERVER->LoadInstrument($1, $3, $5); } @@ -405,6 +506,9 @@ | number { $$ = $1; } ; +effect_control_value : real + ; + sampler_channel : number ; @@ -417,40 +521,48 @@ engine_name : string ; -pathname : stringval +filename : path { + #if WIN32 + $$ = $1.toWindows(); + #else + // assuming POSIX + $$ = $1.toPosix(); + #endif + } ; -dirname : stringval +db_path : path { $$ = $1.toDbPath(); } ; -filename : stringval +map_name : stringval_escaped ; -map_name : stringval +entry_name : stringval_escaped ; -entry_name : stringval +fx_send_name : stringval_escaped ; -fx_send_name : stringval +effect_name : stringval_escaped ; param_val_list : param_val | param_val_list','param_val { $$ = $1 + "," + $3; } ; -param_val : string - | stringval +//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 +param_val : string { $$ = "\'" + $1 + "\'"; } + | stringval { $$ = "\'" + $1 + "\'"; } | number { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } - | dotnum { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } + | dotnum { std::stringstream ss; ss << "\'" << $1 << "\'"; $$ = ss.str(); } //TODO: maybe better using 'real' instead of 'number' and 'dotnum' rules ; query_val_list : string '=' query_val { $$[$1] = $3; } | query_val_list SP string '=' query_val { $$ = $1; $$[$3] = $5; } ; -query_val : string - | stringval +query_val : text_escaped + | stringval_escaped ; scan_mode : RECURSIVE { $$ = "RECURSIVE"; } @@ -467,13 +579,17 @@ | string { $$ = -1; } ; -string : char { std::string s; s = $1; $$ = s; } - | string char { $$ = $1 + $2; } +dotnum : digits '.' digits { std::stringstream ss($1 + "." + $3); ss.imbue(std::locale::classic()); ss >> $$; } + | '+' digits '.' digits { std::stringstream ss($2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; } + | '-' digits '.' digits { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; } ; -dotnum : digits '.' digits { $$ = atof(String($1 + "." + $3).c_str()); } - | '+' digits '.' digits { String s = "+"; s += $2; s += "."; s += $4; $$ = atof(s.c_str()); } - | '-' digits '.' digits { $$ = atof(String("-" + $2 + "." + $4).c_str()); } +real : digits '.' digits { std::stringstream ss($1 + "." + $3); ss.imbue(std::locale::classic()); ss >> $$; } + | '+' digits '.' digits { std::stringstream ss($2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; } + | '-' digits '.' digits { std::stringstream ss("-" + $2 + "." + $4); ss.imbue(std::locale::classic()); ss >> $$; } + | digits { std::stringstream ss($1); ss.imbue(std::locale::classic()); ss >> $$; } + | '+' digits { std::stringstream ss($2); ss.imbue(std::locale::classic()); ss >> $$; } + | '-' digits { std::stringstream ss("-" + $2); ss.imbue(std::locale::classic()); ss >> $$; } ; @@ -493,6 +609,40 @@ | '9' { $$ = '9'; } ; +digit_oct : '0' { $$ = '0'; } + | '1' { $$ = '1'; } + | '2' { $$ = '2'; } + | '3' { $$ = '3'; } + | '4' { $$ = '4'; } + | '5' { $$ = '5'; } + | '6' { $$ = '6'; } + | '7' { $$ = '7'; } + ; + +digit_hex : '0' { $$ = '0'; } + | '1' { $$ = '1'; } + | '2' { $$ = '2'; } + | '3' { $$ = '3'; } + | '4' { $$ = '4'; } + | '5' { $$ = '5'; } + | '6' { $$ = '6'; } + | '7' { $$ = '7'; } + | '8' { $$ = '8'; } + | '9' { $$ = '9'; } + | 'a' { $$ = 'a'; } + | 'b' { $$ = 'b'; } + | 'c' { $$ = 'c'; } + | 'd' { $$ = 'd'; } + | 'e' { $$ = 'e'; } + | 'f' { $$ = 'f'; } + | 'A' { $$ = 'a'; } + | 'B' { $$ = 'b'; } + | 'C' { $$ = 'c'; } + | 'D' { $$ = 'd'; } + | 'E' { $$ = 'e'; } + | 'F' { $$ = 'f'; } + ; + number : digit { $$ = atoi(String(1, $1).c_str()); } | '1' digits { $$ = atoi(String(String("1") + $2).c_str()); } | '2' digits { $$ = atoi(String(String("2") + $2).c_str()); } @@ -503,57 +653,30 @@ | '7' digits { $$ = atoi(String(String("7") + $2).c_str()); } | '8' digits { $$ = atoi(String(String("8") + $2).c_str()); } | '9' digits { $$ = atoi(String(String("9") + $2).c_str()); } + ; -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'; } - | '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'; } - | '0' { $$ = '0'; } | '1' { $$ = '1'; } | '2' { $$ = '2'; } | '3' { $$ = '3'; } | '4' { $$ = '4'; } | '5' { $$ = '5'; } | '6' { $$ = '6'; } | '7' { $$ = '7'; } | '8' { $$ = '8'; } | '9' { $$ = '9'; } - | '!' { $$ = '!'; } | '#' { $$ = '#'; } | '$' { $$ = '$'; } | '%' { $$ = '%'; } | '&' { $$ = '&'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } | '*' { $$ = '*'; } | '+' { $$ = '+'; } | '-' { $$ = '-'; } | '.' { $$ = '.'; } | ',' { $$ = ','; } | '/' { $$ = '/'; } - | ':' { $$ = ':'; } | ';' { $$ = ';'; } | '<' { $$ = '<'; } | '=' { $$ = '='; } | '>' { $$ = '>'; } | '?' { $$ = '?'; } | '@' { $$ = '@'; } - | '[' { $$ = '['; } | '\\' { $$ = '\\'; } | ']' { $$ = ']'; } | '^' { $$ = '^'; } | '_' { $$ = '_'; } - | '{' { $$ = '{'; } | '|' { $$ = '|'; } | '}' { $$ = '}'; } | '~' { $$ = '~'; } - | '\200' { $$ = '\200'; } | '\201' { $$ = '\201'; } | '\202' { $$ = '\202'; } - | '\203' { $$ = '\203'; } | '\204' { $$ = '\204'; } | '\205' { $$ = '\205'; } - | '\206' { $$ = '\206'; } | '\207' { $$ = '\207'; } | '\210' { $$ = '\210'; } - | '\211' { $$ = '\211'; } | '\212' { $$ = '\212'; } | '\213' { $$ = '\213'; } - | '\214' { $$ = '\214'; } | '\215' { $$ = '\215'; } | '\216' { $$ = '\216'; } - | '\217' { $$ = '\217'; } | '\220' { $$ = '\220'; } | '\221' { $$ = '\221'; } - | '\222' { $$ = '\222'; } | '\223' { $$ = '\223'; } | '\224' { $$ = '\224'; } - | '\225' { $$ = '\225'; } | '\226' { $$ = '\226'; } | '\227' { $$ = '\227'; } - | '\230' { $$ = '\230'; } | '\231' { $$ = '\231'; } | '\232' { $$ = '\232'; } - | '\233' { $$ = '\233'; } | '\234' { $$ = '\234'; } | '\235' { $$ = '\235'; } - | '\236' { $$ = '\236'; } | '\237' { $$ = '\237'; } | '\240' { $$ = '\240'; } - | '\241' { $$ = '\241'; } | '\242' { $$ = '\242'; } | '\243' { $$ = '\243'; } - | '\244' { $$ = '\244'; } | '\245' { $$ = '\245'; } | '\246' { $$ = '\246'; } - | '\247' { $$ = '\247'; } | '\250' { $$ = '\250'; } | '\251' { $$ = '\251'; } - | '\252' { $$ = '\252'; } | '\253' { $$ = '\253'; } | '\254' { $$ = '\254'; } - | '\255' { $$ = '\255'; } | '\256' { $$ = '\256'; } | '\257' { $$ = '\257'; } - | '\260' { $$ = '\260'; } | '\261' { $$ = '\261'; } | '\262' { $$ = '\262'; } - | '\263' { $$ = '\263'; } | '\264' { $$ = '\264'; } | '\265' { $$ = '\265'; } - | '\266' { $$ = '\266'; } | '\267' { $$ = '\267'; } | '\270' { $$ = '\270'; } - | '\271' { $$ = '\271'; } | '\272' { $$ = '\272'; } | '\273' { $$ = '\273'; } - | '\274' { $$ = '\274'; } | '\275' { $$ = '\275'; } | '\276' { $$ = '\276'; } - | '\277' { $$ = '\277'; } | '\300' { $$ = '\300'; } | '\301' { $$ = '\301'; } - | '\302' { $$ = '\302'; } | '\303' { $$ = '\303'; } | '\304' { $$ = '\304'; } - | '\305' { $$ = '\305'; } | '\306' { $$ = '\306'; } | '\307' { $$ = '\307'; } - | '\310' { $$ = '\310'; } | '\311' { $$ = '\311'; } | '\312' { $$ = '\312'; } - | '\313' { $$ = '\313'; } | '\314' { $$ = '\314'; } | '\315' { $$ = '\315'; } - | '\316' { $$ = '\316'; } | '\317' { $$ = '\317'; } | '\320' { $$ = '\320'; } - | '\321' { $$ = '\321'; } | '\322' { $$ = '\322'; } | '\323' { $$ = '\323'; } - | '\324' { $$ = '\324'; } | '\325' { $$ = '\325'; } | '\326' { $$ = '\326'; } - | '\327' { $$ = '\327'; } | '\330' { $$ = '\330'; } | '\331' { $$ = '\331'; } - | '\332' { $$ = '\332'; } | '\333' { $$ = '\333'; } | '\334' { $$ = '\334'; } - | '\335' { $$ = '\335'; } | '\336' { $$ = '\336'; } | '\337' { $$ = '\337'; } - | '\340' { $$ = '\340'; } | '\341' { $$ = '\341'; } | '\342' { $$ = '\342'; } - | '\343' { $$ = '\343'; } | '\344' { $$ = '\344'; } | '\345' { $$ = '\345'; } - | '\346' { $$ = '\346'; } | '\347' { $$ = '\347'; } | '\350' { $$ = '\350'; } - | '\351' { $$ = '\351'; } | '\352' { $$ = '\352'; } | '\353' { $$ = '\353'; } - | '\354' { $$ = '\354'; } | '\355' { $$ = '\355'; } | '\356' { $$ = '\356'; } - | '\357' { $$ = '\357'; } | '\360' { $$ = '\360'; } | '\361' { $$ = '\361'; } - | '\362' { $$ = '\362'; } | '\363' { $$ = '\363'; } | '\364' { $$ = '\364'; } - | '\365' { $$ = '\365'; } | '\366' { $$ = '\366'; } | '\367' { $$ = '\367'; } - | '\370' { $$ = '\370'; } | '\371' { $$ = '\371'; } | '\372' { $$ = '\372'; } - | '\373' { $$ = '\373'; } | '\374' { $$ = '\374'; } | '\375' { $$ = '\375'; } - | '\376' { $$ = '\376'; } | '\377' { $$ = '\377'; } +path : '\'' path_base '\'' { $$ = $2; } + | '\"' path_base '\"' { $$ = $2; } + ; + +path_base : path_prefix path_body { $$ = $1 + $2; } + ; + +path_prefix : '/' { $$ = Path(); } + | alpha_char ':' '/' { Path p; p.setDrive($1); $$ = p; } + ; + +path_body : /* epsilon (empty argument) */ { $$ = Path(); } + | path_body '/' { $$ = $1; } + | path_body text_escaped_base { Path p; p.appendNode($2); $$ = $1 + p; } + ; + +stringval : '\'' text '\'' { $$ = $2; } + | '\"' text '\"' { $$ = $2; } + ; + +stringval_escaped : '\'' text_escaped '\'' { $$ = $2; } + | '\"' text_escaped '\"' { $$ = $2; } ; text : SP { $$ = " "; } @@ -562,10 +685,71 @@ | text string { $$ = $1 + $2; } ; -stringval : '\'' text '\'' { $$ = $2; } - | '\"' text '\"' { $$ = $2; } +// like text_escaped, but missing the slash ('/') character +text_escaped_base : SP { $$ = " "; } + | string_escaped + | text_escaped_base SP { $$ = $1 + " "; } + | text_escaped_base string_escaped { $$ = $1 + $2; } ; +text_escaped : '/' { $$ = "/"; } + | text_escaped_base + | text_escaped '/' { $$ = $1 + "/"; } + | text_escaped text_escaped_base { $$ = $1 + $2; } + ; + +string : char { std::string s; s = $1; $$ = s; } + | string char { $$ = $1 + $2; } + ; + +string_escaped : char_base { std::string s; s = $1; $$ = s; } + | escape_seq { std::string s; s = $1; $$ = s; } + | string_escaped char_base { $$ = $1 + $2; } + | string_escaped escape_seq { $$ = $1 + $2; } + ; + +// full ASCII character set except space, quotation mark and apostrophe +char : char_base + | '\\' { $$ = '\\'; } + | '/' { $$ = '/'; } + ; + +// characters A..Z and a..z +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'; } + | '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'; } + ; + +// ASCII characters except space, quotation mark, apostrophe, backslash and slash +char_base : alpha_char + | '0' { $$ = '0'; } | '1' { $$ = '1'; } | '2' { $$ = '2'; } | '3' { $$ = '3'; } | '4' { $$ = '4'; } | '5' { $$ = '5'; } | '6' { $$ = '6'; } | '7' { $$ = '7'; } | '8' { $$ = '8'; } | '9' { $$ = '9'; } + | '!' { $$ = '!'; } | '#' { $$ = '#'; } | '$' { $$ = '$'; } | '%' { $$ = '%'; } | '&' { $$ = '&'; } | '(' { $$ = '('; } | ')' { $$ = ')'; } | '*' { $$ = '*'; } | '+' { $$ = '+'; } | '-' { $$ = '-'; } | '.' { $$ = '.'; } | ',' { $$ = ','; } + | ':' { $$ = ':'; } | ';' { $$ = ';'; } | '<' { $$ = '<'; } | '=' { $$ = '='; } | '>' { $$ = '>'; } | '?' { $$ = '?'; } | '@' { $$ = '@'; } + | '[' { $$ = '['; } | ']' { $$ = ']'; } | '^' { $$ = '^'; } | '_' { $$ = '_'; } + | '{' { $$ = '{'; } | '|' { $$ = '|'; } | '}' { $$ = '}'; } | '~' { $$ = '~'; } + | EXT_ASCII_CHAR + ; + +escape_seq : '\\' '\'' { $$ = '\''; } + | '\\' '\"' { $$ = '\"'; } + | '\\' '\\' { $$ = '\\'; } + | '\\' '/' { $$ = '/'; } + | '\\' 'n' { $$ = '\n'; } + | '\\' 'r' { $$ = '\r'; } + | '\\' 'f' { $$ = '\f'; } + | '\\' 't' { $$ = '\t'; } + | '\\' 'v' { $$ = '\v'; } + | escape_seq_octal + | escape_seq_hex + ; + +escape_seq_octal : '\\' digit_oct { $$ = (char) octalsToNumber($2); } + | '\\' digit_oct digit_oct { $$ = (char) octalsToNumber($3,$2); } + | '\\' digit_oct digit_oct digit_oct { $$ = (char) octalsToNumber($4,$3,$2); } + ; + +escape_seq_hex : '\\' 'x' digit_hex { $$ = (char) hexsToNumber($3); } + | '\\' 'x' digit_hex digit_hex { $$ = (char) hexsToNumber($4,$3); } + ; // rules which are more or less just terminal symbols @@ -596,6 +780,9 @@ FIND : 'F''I''N''D' ; +FILE_AS_DIR : 'F''I''L''E''_''A''S''_''D''I''R' + ; + MOVE : 'M''O''V''E' ; @@ -632,6 +819,12 @@ SET : 'S''E''T' ; +APPEND : 'A''P''P''E''N''D' + ; + +INSERT : 'I''N''S''E''R''T' + ; + SUBSCRIBE : 'S''U''B''S''C''R''I''B''E' ; @@ -689,12 +882,21 @@ DB_INSTRUMENT_INFO : 'D''B''_''I''N''S''T''R''U''M''E''N''T''_''I''N''F''O' ; +DB_INSTRUMENT_FILES : 'D''B''_''I''N''S''T''R''U''M''E''N''T''_''F''I''L''E''S' + ; + DB_INSTRUMENTS_JOB_INFO : 'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B''_''I''N''F''O' ; CHANNEL_COUNT : 'C''H''A''N''N''E''L''_''C''O''U''N''T' ; +CHANNEL_MIDI : 'C''H''A''N''N''E''L''_''M''I''D''I' + ; + +DEVICE_MIDI : 'D''E''V''I''C''E''_''M''I''D''I' + ; + CHANNEL_INFO : 'C''H''A''N''N''E''L''_''I''N''F''O' ; @@ -713,6 +915,9 @@ VOICE_COUNT : 'V''O''I''C''E''_''C''O''U''N''T' ; +TOTAL_STREAM_COUNT : 'T''O''T''A''L''_''S''T''R''E''A''M''_''C''O''U''N''T' + ; + TOTAL_VOICE_COUNT : 'T''O''T''A''L''_''V''O''I''C''E''_''C''O''U''N''T' ; @@ -725,6 +930,9 @@ INSTRUMENT : 'I''N''S''T''R''U''M''E''N''T' ; +INSTRUMENTS : 'I''N''S''T''R''U''M''E''N''T''S' + ; + ENGINE : 'E' 'N' 'G' 'I' 'N' 'E' ; @@ -761,6 +969,27 @@ AUDIO_OUTPUT_TYPE : 'A''U''D''I''O''_''O''U''T''P''U''T''_''T''Y''P''E' ; +AVAILABLE_EFFECTS : 'A''V''A''I''L''A''B''L''E''_''E''F''F''E''C''T''S' + ; + +EFFECT : 'E''F''F''E''C''T' + ; + +EFFECT_INSTANCE : 'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E' + ; + +EFFECT_INSTANCES : 'E''F''F''E''C''T''_''I''N''S''T''A''N''C''E''S' + ; + +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' + ; + +MASTER_EFFECT_CHAIN : 'M''A''S''T''E''R''_''E''F''F''E''C''T''_''C''H''A''I''N' + ; + +MASTER_EFFECT_CHAINS : 'M''A''S''T''E''R''_''E''F''F''E''C''T''_''C''H''A''I''N''S' + ; + AVAILABLE_MIDI_INPUT_DRIVERS : 'A''V''A''I''L''A''B''L''E''_''M''I''D''I''_''I''N''P''U''T''_''D''R''I''V''E''R''S' ; @@ -809,6 +1038,9 @@ MIDI_CONTROLLER : 'M''I''D''I''_''C''O''N''T''R''O''L''L''E''R' ; +SEND : 'S''E''N''D' + ; + FX_SEND : 'F''X''_''S''E''N''D' ; @@ -830,6 +1062,9 @@ DB_INSTRUMENTS_JOB : 'D''B''_''I''N''S''T''R''U''M''E''N''T''S''_''J''O''B' ; +INSTRUMENTS_DB : 'I''N''S''T''R''U''M''E''N''T''S''_''D''B' + ; + DESCRIPTION : 'D''E''S''C''R''I''P''T''I''O''N' ; @@ -845,6 +1080,12 @@ NON_RECURSIVE : 'N''O''N''_''R''E''C''U''R''S''I''V''E' ; +LOST : 'L''O''S''T' + ; + +FILE_PATH : 'F''I''L''E''_''P''A''T''H' + ; + SERVER : 'S''E''R''V''E''R' ; @@ -860,15 +1101,30 @@ SOLO : 'S''O''L''O' ; +VOICES : 'V''O''I''C''E''S' + ; + +STREAMS : 'S''T''R''E''A''M''S' + ; + BYTES : 'B''Y''T''E''S' ; PERCENTAGE : 'P''E''R''C''E''N''T''A''G''E' ; +FILE : 'F''I''L''E' + ; + EDIT : 'E''D''I''T' ; +FORMAT : 'F''O''R''M''A''T' + ; + +MIDI_DATA : 'M''I''D''I''_''D''A''T''A' + ; + RESET : 'R''E''S''E''T' ; @@ -890,13 +1146,24 @@ * Will be called when an error occured (usually syntax error). */ void yyerror(const char* s) { - dmsg(2,("LSCPParser: %s\n", s)); + yyparse_param_t* param = GetCurrentYaccSession(); + String msg = s + + (" (line:" + ToString(param->iLine+1)) + + ( ",column:" + ToString(param->iColumn)) + + ")"; + dmsg(2,("LSCPParser: %s\n", msg.c_str())); + sLastError = msg; } +namespace LinuxSampler { + /** * Clears input buffer. */ void restart(yyparse_param_t* pparam, int& yychar) { bytes = 0; ptr = 0; + sLastError = ""; +} + }