Added a section to the BasicParse article covering making changes/additions to the code.

The first parser was fairly straightforward, but the first question I got was related to making changes because the format was too verbose or unsuitable for certain types of configs.  That is always going to happen.  Heck, why does C# use for instead of 4, or using instead of u.  Programming languages tend to emphasize just the right amount of verbosity to avoid ambiguity.  In the case of our processing language, we didn't want the association between complex types and basic value types to be muddied, so it was required that a complex type be denoted by a nesting statement {} and that a simple type be denoted by an assignment statement =.

The modification is to allow simple types to not have assignment and value statements and to let simple types be defined as valueless in some circumstances.  This adds ambiguity to our resulting language because complex types are represented by an element with no attributes, and a simple type with no value will be represented the same way.  I think it is important to add a sample modification to the parser though, so I've covered making this addition.

Here is a sample of the new config that will get parsed:

forwarders { 192.168.0.1; 192.168.0.2; }

Note this would have the same output as:

forwarders { 192.168.0.1{} 192.168.0.2 {} }

To remove the ambiguity, you could force some additional output into the finalized XML stream that would let you tell the difference.  I don't cover this because I don't think it is that important.

BasicParse, a parser/compiler for a pseudo Bind configuration file format.

Published Sunday, May 16, 2004 3:14 PM by Justin Rogers

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)