Let's start with a sample of the config/console language. The following is written as a configuration file
# My someserver configuration file /server/port 1234; /logger/targets { console { accept senf::log::Debug IMPORTANT; accept server::ServerLog CRITICAL; } provide serverlog senf::log::FileTarget "/var/log/server.log"; serverlog { reject senf::log::Debug senf::Console::Server NOTICE; accept senf::log::Debug NOTICE; accept server::ServerLog; } } /server/stuffing (UDPPacket x"01 02 03 04"); /server/allow_hosts 10.1.2.3 # our internal server 10.2.3.4 10.4.3.5 # client workstations ; /help/infoUrl "http://senf.j32.de/src/doc";
The interactive syntax is the same with some notes:
# | Comments are marked with '#' and continue to the end of the line |
/ | path component separator |
( ) | argument grouping |
{ } | directory grouping |
; | command terminator |
, = | punctuation tokens |
12.34 jens@fit.fraunhofer.de eth0 1>2
The following are not valid words:
a/b/c a,b
A string literal is just that: A double-quoted string (C/C++ style) possibly with embedded escape chars:
"\"foo\"" "\x04test"
A hex-string literal is used to represent binary data. It looks like a string which has only hexadecimal bytes or whitespace as contents (comments and newlines are Ok when not read from the interactive console)
x"01 02 03 0405" x"01 02 # ID header 0405 # payload "
A token is a word, string or hex-string, or a single special character (that's true, any special character is allowed as a token). '(' and ')' must be properly nested.
A path is a sequence of words separated by '/' (and optional whitespace). A path may have an optional initial and/or a terminating '/'.
a/b/c foo / bar / /server
/path/to/command arg1 "arg2" (complex=(1 2) another) ;Every argument is either
A built-in statement is one of
cd path
|
Change current directory |
ls [ path ] |
List contents of path or current directory |
exit |
Exit interactive console |
help [ path ] |
Show help for path or current directory |
A directory group statement is a block of statements all executed relatively to a fixed directory.
/some/path { statement ; . . . }At the beginning of the block, the current directory is saved and the directory is changed to the given directory. All commands are executed and at the end of the block, the saved directory is restored.
Every statement is returned as a senf::console::ParseCommandInfo instance. Directory groups are handled specially: They are divided into two special built-in commands called PUSHD and POPD.
3. Classes |
|
class | senf::console::Token |
Single argument token. More... |
|
class | senf::console::ParseCommandInfo |
Single parsed console command. More... |
|
class | senf::console::CommandParser |
Parse commands. More... |