W
William Stacey [MVP]
BTW. The html doco on bind (and src and binaries) are available at
www.ics.org. If you ever have any questions on bind or w2k dns, I will be
most happy to help or find an answer for you. Cheers!
--
William Stacey, MVP
www.ics.org. If you ever have any questions on bind or w2k dns, I will be
most happy to help or find an answer for you. Cheers!
--
William Stacey, MVP
Justin Rogers said:I've gone the basic route. You can fine the article and full code for a parse
that does
a pseudo-bind format. My format might support something like:
bind {
recursion = true;
forwarders {
0 = "192.168.0.1"; 1 = "192.168.0.2";
}
view1 {
zone1 {
name = "mydomain.com";
forwarders {
0 = "192.168.0.1"; 1 = "192.168.0.2";
}
}
}
}
Note, that I am going to finally implement the full bind configuration format,
not because I have
to, but because I think it would be kind of cool. The result of my compiler is
an Xml file format,
but you could easily evolve the compiler to spit out another format if you
wished. I point out in
the article that I do semantic processing in two places. If you wanted a parser
rather than a
linked parser/compiler module, then there are some things that would have to be
changed to be
more efficient to that form of program. With a parser module, you'd expect some
abstract output
that you would then input to a compiler module that would create the final view.
I've simply linked
these two steps into one because it is common and easy to do for small
languages.
http://weblogs.asp.net/justin_rogers/archive/2004/05/16/132744.aspx
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
If you are going to go this far, why not make it full blown syntax?William Stacey said:Your the man! That is sweet. You gave me an idea. It might be
interesting
to use c# code style over the bind style. The bind is good and what I was
after, but the c# style would be a very cool twist and I am not tied to
the
bind but for the common use of it. How could/should I define the same
kind
of config using c# style such as below and will this work?
class BindConfig
{
bool recursion = true;
IPAddress[] forwarders = {"192.168.0.1", "192.168.0.2"}; // not sure
here
class View1
{
class Zone1
{
string name = "mydomain.com.";
IPAddress[] forwarders = ...
}
}
class View2
{
// other zones.
}
}
Not sure if this is better or not, but could be flexible.
config Bind
{
bool recursion = true;
IPAddress[] forwards = {192.168.0.1, 192.168.0.2};
view basicView
{
zone FooZone
{
string name = "mydomain.com";
IPAddress[] forwarders = ...
}
}
}
or wahtever is specifica to your needs. Justins lexer is probably flexible
enough to do this, although the parser would probably need a bit of work for
type verification and the like. The flexibility is there, its just a matter
of designing it and writing the parser. When you get into typing, c style
strings, and the like the lexer and\or parser(depending on your design)
become a bit more complex, although not prohibitivly so.
Normally I don't need to be spoon fed, but this stuff is a bit new to me.
Very much appreciate your help and interest.
--
William Stacey, MVP
Phew, that makes my lexer look bulky,(536 lines so far). Granted it
supports several literal formats(string, integers and double right
now).
Yes, the lexer could be more advanced. Notice in a second post, I took
out even more code bringing the 39 lines to only 30 (for the lexer), but
added the necessary namespace imports and a test driver.
http://weblogs.asp.net/justin_rogers/archive/2004/05/15/132693.aspx
Out of curiosity, what are you using for your parser? Are you using a
parser
generator or just writing one by hand? I imagine I could wait for you
to
post the article, but I am curious.
I generally write my parser's by hand. It doesn't take much. I'm not at
the
machine with the parser on it right now so I can't tell you the number of
lines
to parse the Bind configuration file (thanks to William for pointing out
the
source of this configuration format), but it is relatively short, on the
order
of
only 100-150 with comments. There is some code to build the XmlDocument
object (note this is not a straight parser, but rather a parser +
compiler
module
that compiles the Bind configuration file into XmlDocument). I'll have
the
article
up shortly.