Hi everyone, I have a parsing problem which I don't know how to solve the best way. In short, it is that I need to parse XML.[1] The problem's essence is shown in this example:
<prefix:name attr1="content" prefix:attr2="content2" xmlns:prefix="example.org/HereIsPrefixDeclared"/> The problem is that "xmlns:prefix" declares the prefix 'prefix', but it is used before it is declared. It's used in "prefix:name" and "prefix:attr2". In other words, this is a problem in the same direction of the example in "Actions in Mid-Rule"(bison manual), but a bit more tricky. In my case, I find the attributes simple to handle. I retrieve all the attributes and they don't need any namespace declarations because I deal with it manually in the action. However, the start tag, "prefix:name", is a bit more problematic. I could of course just deal with it manually, but I would really want to push it down into an action, and have it dealt with there. Here's how I would like to do: to let the parser tokenize and see what rules to use, but to wait with invoking the actual action for the rule handling "<prefix:name", until all the attributes are parsed. Since then the namespace declarations(attributes) have populated my parse "context" with declarations. Is anything in that direction possible? Another solution is to add a layer of indirection. Instead of letting the parser resolve namespace declarations, I use "place holders" in my AST, and let an AST-pass do a "fixup". But that surely is heavy and not very elegant, if you ask me. Comments welcome. I would gladly hear about how people solve cases like this. Thanks in advance, Frans 1. Well, not XML 1.0 to be exact, but XML literals occuring in the XQuery language. However, the problem is identical to as if constructing a parser for XML. _______________________________________________ Help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison