Parse tokens in nested parentheses?
-
Howdy all, I'm looking for either a library or a snippet as to how to parse tokens embedded in nested parentheses. For instance, I need to convert something like: (A, B, (C, D)) into a tree like: A B (Parent)->C (Parent)->D Of course, other trees would have different formats: ((A, B), C, D) ((A,B), (C,D)) etc.. I think this borders on a grammar topic, but my brain isn't quite what it used to be ;-( Any suggestions would be welcome. Thanks.
-
Howdy all, I'm looking for either a library or a snippet as to how to parse tokens embedded in nested parentheses. For instance, I need to convert something like: (A, B, (C, D)) into a tree like: A B (Parent)->C (Parent)->D Of course, other trees would have different formats: ((A, B), C, D) ((A,B), (C,D)) etc.. I think this borders on a grammar topic, but my brain isn't quite what it used to be ;-( Any suggestions would be welcome. Thanks.
-
Howdy all, I'm looking for either a library or a snippet as to how to parse tokens embedded in nested parentheses. For instance, I need to convert something like: (A, B, (C, D)) into a tree like: A B (Parent)->C (Parent)->D Of course, other trees would have different formats: ((A, B), C, D) ((A,B), (C,D)) etc.. I think this borders on a grammar topic, but my brain isn't quite what it used to be ;-( Any suggestions would be welcome. Thanks.
I think there is an expression parser in the CodeGuru web site but there might be one in this web site too. They might help but might be too much. I think you only need a syntactical parser. You probably do not need a symantics parser. Are you familiar with Lexx? It is a compiler that generates a syntactical parser written in C. Also see: http://www.snippets.org/ and look for "Jari Laaksonen's comment utilities in C++" near the bottom. It might help.