From: stephan b. <st...@ei...> - 2003-09-05 11:36:23
|
okay, i've gotten carried away... the ser-txt parser can now handle a more useful superset of the txt format. Here's an example which shows the current possibilities: /* comment block */ // single-line comment # single-line comment ; single-line comment myfoo class=FooClass { gameboxName G.E.V. gameboxVers = 0.1 // ^^^ optional = sign for property declarations. mybar class=BarClass { myprop 17 myotherprop "this string here, seen?" /*********** we don't serve their kind here: ohno class=NoExistie { canyouinstantiateme = no canyouinstantiateme2 = no2 canyouinstantiateme3 = no3 } ohno class=NoExistie { canyouinstantiateme = no } ohno class=NoExistie { canyouinstantiateme = no } ***********/ } }; # ^^^ optional trailing semicolon root_too class=FooClass { the_real_node #42.42 # strings: backslashes and outer quotes will get # stripped and newlines normalized: quoted_string="this is a quoted string" unquoted_string this is an unquoted string squoted_string 'this is a \ single-quoted \ string' mstring "this is a \ \"multi-line\" \ string" another semi-colon val; key = semi-colon val; # semicolon gets stripped. SOURCES = foo \ elib_globals.cpp \ ECommandLiner.cpp \ EInputProcessor.cpp \ EEnvironment.cpp \ EInputProcessorChain.cpp \ EInputDispatcher.cpp \ EKeyValueParser.cpp \ ELib.cpp \ EPointerList.cpp \ ESimpleCLParser.cpp \ EStdStringTokenizer.cpp \ EStringTokenizer.cpp \ EPathFinder.cpp \ EPropertyList.cpp \ EReadline.cpp \ EShellProcess.cpp \ EStringList.cpp } possible todos: add protocol level check for, e.g.: #SerialTree text_v2 nodename class=Foo X where X is some positive integer - the object would be replicated that number of times. # nodename class=Foo comment out the whole node if the node decl is commented out. i'll check this into the fun tree once i'm happy with it. The code does not yet build a proper tree (i'm using property lists for everything at the moment), but the parser is agnostic in regards to the tree structure, using a set of 3 callbacks to open/close nodes and add props to the current node. -- ----- stephan st...@ei... - http://www.einsurance.de "...control is a degree of inhibition, and a system which is perfectly inhibited is completely frozen." -- Alan W. Watts |