|
From: Simon J. <sje...@bl...> - 2004-06-19 21:12:35
|
Vladimir ~
I've knocked together some test files, attached.
The lexical analyser handles strings (double-quoted, but that could be
changed) including C-style
escapes (\n, \t etc) and names, ie unquoted strings of the form
[A-Za-z_][A-Za-z0-9_]*.
It doesn't know that "names MUST not be all upper case", but it doesn't
have to... thats a rule
for developers to follow, and if they break it then things might not
work. It also handles the
whitespace and comments, so the parser doesn't have to.
The parser can understand a few of the lscp commands, including the
CREATE AUDIO_OUTPUT_DEVICE command with multiple key/value parameters
which is
the one I was a bit worried about. When it understands a command it
calls a fake LSCPSERVER
which prints out the calls and the parameters it gets.
to build the test:
1) Put the attached files in a directory
2) type "make"
to run the test:
1) type "./test"
2) type any one of the six lscp commands that the test parser so far
understands
3) hit return
4) goto 2)
eg you type...
CREATE AUDIO_OUTPUT_DEVICE Test Hair="Red" Eyes="Blue" Age=23
and you should see...
CreateAudioOutputDevice() called.
Name: Test
Param: Hair = "Red"
Param: Eyes = "Blue"
Param: Age = 23
AnswerClient() called with string "Response".
Its a bit messy in places, but it handles what needed to be handled. You can
take whatever you find useful from it and ignore the rest.
Simon Jenkins
(Bristol, UK)
|