-
Notifications
You must be signed in to change notification settings - Fork 2
Example hosts
Stefan Koch edited this page Feb 23, 2015
·
3 revisions
Source to parse :
hosts{
myhost="www.myhost.com";
myhost2="www.myhost2.com";
}
FancyPars-grammar :
ConfigNode {
Identifier @internal {
[a-zA-Z_0-9][] identifier
}
String @internal {
"\"", char[] string_, "\""
}
HostEntry @internal {
Identifier name, "=", String host
}
HostConfig {
"hosts", "{", HostEntry[] hosts : ";", "}"
}
}This will produce the following AST.d
abstract class ConfigNode {}
class Identifier : ConfigNode {
char[] identifier;
this(char[] identifier) {
this.identifier = identifier;
}
}
class String : ConfigNode {
char[] string_;
this(char[] string_) {
this.string_ = string_;
}
}
class HostEntry : ConfigNode {
Identifier name;
String host;
this(Identifier name, String host) {
this.name = name;
this.host = host;
}
}
class HostConfig : ConfigNode {
HostEntry[] hosts;
this(HostEntry[] hosts) {
this.hosts = hosts;
}
}