/[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 1245 by schoenebeck, Tue Jun 19 15:54:13 2007 UTC revision 1296 by iliev, Wed Aug 15 17:43:34 2007 UTC
# Line 37  Line 37 
37    
38  // to save us typing work in the rules action definitions  // to save us typing work in the rules action definitions
39  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer  #define LSCPSERVER ((yyparse_param_t*) yyparse_param)->pServer
40    #define SESSION_PARAM ((yyparse_param_t*) yyparse_param)
41    #define INCREMENT_LINE { SESSION_PARAM->iLine++; SESSION_PARAM->iColumn = 0; }
42    
43  // clears input buffer  // clears input buffer
44  void restart(yyparse_param_t* pparam, int& yychar);  void restart(yyparse_param_t* pparam, int& yychar);
# Line 48  void yyerror(const char* s); Line 50  void yyerror(const char* s);
50  static char buf[1024]; // input buffer to feed the parser with new characters  static char buf[1024]; // input buffer to feed the parser with new characters
51  static int bytes = 0;  // current number of characters in the input buffer  static int bytes = 0;  // current number of characters in the input buffer
52  static int ptr   = 0;  // current position in the input buffer  static int ptr   = 0;  // current position in the input buffer
53    static String sLastError; // error message of the last error occured
54    
55  // external reference to the function which actually reads from the socket  // external reference to the function which actually reads from the socket
56  extern int GetLSCPCommand( void *buf, int max_size);  extern int GetLSCPCommand( void *buf, int max_size);
57    
58    // external reference to the function in lscpserver.cpp which returns the
59    // current session (only works because the server runs as singleton)
60    extern yyparse_param_t* GetCurrentYaccSession();
61    
62  // returns true if supplied characters has an ASCII code of 128 or higher  // returns true if supplied characters has an ASCII code of 128 or higher
63  inline bool isExtendedAsciiChar(const char c) {  inline bool isExtendedAsciiChar(const char c) {
64      return (c < 0);      return (c < 0);
# Line 72  int yylex(YYSTYPE* yylval) { Line 79  int yylex(YYSTYPE* yylval) {
79      }      }
80      // this is the next character in the input stream      // this is the next character in the input stream
81      const char c = buf[ptr++];      const char c = buf[ptr++];
82        // increment current reading position (just for verbosity / messages)
83        GetCurrentYaccSession()->iColumn++;
84      // we have to handle "normal" and "extended" ASCII characters separately      // we have to handle "normal" and "extended" ASCII characters separately
85      if (isExtendedAsciiChar(c)) {      if (isExtendedAsciiChar(c)) {
86          // workaround for characters with ASCII code higher than 127          // workaround for characters with ASCII code higher than 127
# Line 123  int hexsToNumber(char hex_digit0, char h Line 132  int hexsToNumber(char hex_digit0, char h
132    
133  // reentrant parser  // reentrant parser
134  %pure_parser  %pure_parser
135    
136    // tell bison to spit out verbose syntax error messages
137  %error-verbose  %error-verbose
138    
139  %token <Char> EXT_ASCII_CHAR  %token <Char> EXT_ASCII_CHAR
# Line 155  input                 : line LF Line 166  input                 : line LF
166                        | line CR LF                        | line CR LF
167                        ;                        ;
168    
169  line                  :  /* epsilon (empty line ignored) */ { return LSCP_DONE; }  line                  :  /* epsilon (empty line ignored) */ { INCREMENT_LINE; return LSCP_DONE; }
170                        |  comment  { return LSCP_DONE; }                        |  comment  { INCREMENT_LINE; return LSCP_DONE; }
171                        |  command  { LSCPSERVER->AnswerClient($1); return LSCP_DONE; }                        |  command  { INCREMENT_LINE; LSCPSERVER->AnswerClient($1); return LSCP_DONE; }
172                        |  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; }
173                        ;                        ;
174    
175  comment               :  '#'  comment               :  '#'
# Line 315  get_instruction       :  AVAILABLE_ENGIN Line 326  get_instruction       :  AVAILABLE_ENGIN
326  set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);      }  set_instruction       :  AUDIO_OUTPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list             { $$ = LSCPSERVER->SetAudioOutputDeviceParameter($3, $5, $7);      }
327                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val_list  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); }                        |  AUDIO_OUTPUT_CHANNEL_PARAMETER SP number SP number SP string '=' param_val_list  { $$ = LSCPSERVER->SetAudioOutputChannelParameter($3, $5, $7, $9); }
328                        |  MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);        }                        |  MIDI_INPUT_DEVICE_PARAMETER SP number SP string '=' param_val_list               { $$ = LSCPSERVER->SetMidiInputDeviceParameter($3, $5, $7);        }
329                          |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' NONE                 { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, "");      }
330                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);      }                        |  MIDI_INPUT_PORT_PARAMETER SP number SP number SP string '=' param_val_list       { $$ = LSCPSERVER->SetMidiInputPortParameter($3, $5, $7, $9);      }
331                        |  CHANNEL SP set_chan_instruction                                                  { $$ = $3;                                                         }                        |  CHANNEL SP set_chan_instruction                                                  { $$ = $3;                                                         }
332                        |  MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name                              { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7);               }                        |  MIDI_INSTRUMENT_MAP SP NAME SP midi_map SP map_name                              { $$ = LSCPSERVER->SetMidiInstrumentMapName($5, $7);               }
# Line 976  QUIT                  :  'Q''U''I''T' Line 988  QUIT                  :  'Q''U''I''T'
988   * Will be called when an error occured (usually syntax error).   * Will be called when an error occured (usually syntax error).
989   */   */
990  void yyerror(const char* s) {  void yyerror(const char* s) {
991      dmsg(2,("LSCPParser: %s\n", s));      yyparse_param_t* param = GetCurrentYaccSession();
992        String msg = s
993            + (" (line:"   + ToString(param->iLine+1))
994            + ( ",column:" + ToString(param->iColumn))
995            + ")";
996        dmsg(2,("LSCPParser: %s\n", msg.c_str()));
997        sLastError = msg;
998  }  }
999    
1000  /**  /**
# Line 985  void yyerror(const char* s) { Line 1003  void yyerror(const char* s) {
1003  void restart(yyparse_param_t* pparam, int& yychar) {  void restart(yyparse_param_t* pparam, int& yychar) {
1004      bytes = 0;      bytes = 0;
1005      ptr   = 0;      ptr   = 0;
1006        sLastError = "";
1007  }  }

Legend:
Removed from v.1245  
changed lines
  Added in v.1296

  ViewVC Help
Powered by ViewVC