Mailing List Archive

This VCL compiler thing...
... is moving nicely along.

I have made some changes to the syntax relative to what we talked
about at the meeting, mostly in order to be able to make the compiler
simpler and to give better error messages.

First of all, I have given all actions a trailing semi-colon.
In case of syntax errors, that will stop the compiler from trying to
make sense of subsequent tokens and that will hopefully limit the
amount of non-sense errors emitted in that case.

I have also decided that all assignments will start out with the
keyword "set".

Finally I have decided to enforce proper types and units throughout,
so if you compare a time variable, you must specify the units:

if (obj.ttl < 10m)

etc.

I have added explicit backend declarations:

backend vg {
set backend.ip = 10.0.0.1, 10.0.0.2, 10.0.0.3;
set backend.timeout = 4s;
set backend.bandwidth = 2000Mb/s;
}

because we need a data structure for each backend.

And this gets me to the something which is a sticky point right
now: IP numbers and IP lists.

With respect to backends, I think we need to declare them individually
because things like response time etc is per backend and not shared
for the cluster of backends. In the above example that would
restrict us to giving one IP#. (We can later expand this to a
concept of backend clusters but I need time to think about data structures
before I make up my mind.

The other thing is matching against IP lists, I think from both a code
and configuration point of view it makes sense to declare IP access lists
explicitly, so that instead of

if (client.ip ~ {10.0.0.0/8,172.16.0,0/12,192.168.0.0/16}) { ...

it would be written

Acl Rfc1918 {
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
}
...

if (client.ip ~ rfc1918) { ...

But I would still allow comparison to a single IP:

if (client.ip = 10.0.1.2) { ...

Still thinking about this though...

The compiler so far is 900 lines of C-code and a 170 line tcl script
to generate some C-code for keyword recognition.

Attached a sample config file and the compiled output as it
looks right now:

begin 664 sample.vcl
M"G-U8B!R97%U97-T7W!O;&EC>2!["@H):68@*&-L:65N="YI<"!^(#$P+C`N
M,"XP+S at I('L*"0EN;U]C86-H93L*"0EF:6YI<V@["@E]"@H):68@*')E<2YU
M<FPN:&]S="!^(")C;FXN;F\D(BD@>PH)"7)E=W)I=&4@(F-N;BYN;R0B(")V
M9RYN;R(["@E]"@H):68@*')E<2YU<FPN<&%T:"!^(")C9VDM8FEN(BD@>PH)
M"6YO7V-A8VAE.PH)?0H*"6EF("AR97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VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@
M("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`I)4$P at 6PI=($E0
M3`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*0HO*B!#;VYD7S$@("`@
M("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*0HO*B!#
M;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N9"`@("`J+R`@("`@>PHO
M*B!!8W1I;VX@("`@("`J+R`@("`@5D-,7VYO7V-A8VAE*"D["B\J($%C=&EO
M;B`@("`@("HO("`@("!R971U<FX["B\J($-O;7!O=6YD("`@("HO("`@("!]
M"B\J($EF4W1M="`@("`@("HO("`@:68@"B\J($-O;F1I=&EO;F%L("HO("`@
M("`H"B\J($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N9%\Q("`@("`@
M*B\@("`@("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`H"B\J
M($-O;F1?4W1R:6YG("HO("`@("`@("`@("`@('-T<FEN9U]M871C:"AR97$N
M=7)L+FAO<W0L(")C;FXN;F\D(BD*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@
M("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@
M("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(%9#3%]R
M97=R:71E*")C;FXN;F\D(BPL(")V9RYN;R(I.PHO*B!#;VUP;W5N9"`@("`J
M+R`@("`@?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA
M;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@
M("`@*`HO*B!#;VYD7U-T<FEN9R`J+R`@("`@("`@("`@("!S=')I;F=?;6%T
M8V at H<F5Q+G5R;"YP871H+"`B8V=I+6)I;B(I"B\J($-O;F1?,B`@("`@("HO
M("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#
M;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I
M"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J($%C=&EO;B`@("`@("HO("`@
M("!60TQ?;F]?8V%C:&4H*3L*+RH at 0V]M<&]U;F0@("`@*B\@("`@('T*+RH@
M2693=&UT("`@("`@*B\@("!I9B`*+RH at 0V]N9&ET:6]N86P@*B\@("`@("@*
M+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*`HO*B!#;VYD7S$@("`@("`J+R`@
M("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N
M9%]3=')I;F<@*B\@("`@("`@("`@("`@<W1R:6YG7VUA=&-H*')E<2YU<V5R
M86=E;G0L(")S<&ED97(B*0HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@
M*0HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@
M*B\@("`@("`@*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N
M9"`@("`J+R`@("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@5D-,7VYO7VYE
M=U]C86-H92 at I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!)9E-T;70@
M("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD
M7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@
M*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@
M("`J+R`@("`@("`@("`@("!B86-K96YD+G)E<W!O;G-E7W1I;64@/B`H,"XX
M("H@,2D*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q
M("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@("D*
M+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@
M('L*+RH at 06-T:6]N("`@("`@*B\@("`@(')E<2YT=&QF86-T;W(@/2`Q+C4[
M"B\J($-O;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@
M96QS92!I9B`*+RH at 0V]N9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@
M("`@*B\@("`@("`@*`HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH@
M0V]N9%\R("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@
M("`@("`@("`@("`@8F%C:V5N9"YR97-P;VYS95]T:6UE(#X@*#$N-2`J(#$I
M"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@
M("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O
M;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J
M($%C=&EO;B`@("`@("HO("`@("!R97$N='1L9F%C=&]R(#T@,CL*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!E;'-E(&EF
M(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@
M("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@
M("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@("`J+R`@("`@("`@
M("`@("!B86-K96YD+G)E<W!O;G-E7W1I;64@/B`H,BXU("H at -C`I"B\J($-O
M;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@("HO("`@
M("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O;F1I=&EO
M;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J($%C=&EO
M;B`@("`@("HO("`@("!R97$N='1L9F%C=&]R(#T at -3L*+RH at 0V]M<&]U;F0@
M("`@*B\@("`@('T*+RH at 0V]M<&]U;F0@("`@*B\@("!]"B\J($)A8VME;F0@
M("`@("HO('-T871I8R!V;VED(%9#3%]B86-K96YD7W9G("AV;VED*0HO*B!#
M;VUP;W5N9"`@("`J+R`@('L*+RH at 06-T:6]N("`@("`@*B\@("!B86-K96YD
M+FEP($E03"!;"ET at 25!,"@HO*B!!8W1I;VX@("`@("`J+R`@(&)A8VME;F0N
M=&EM96]U="`]("@T("H@,2D["B\J($%C=&EO;B`@("`@("HO("`@8F%C:V5N
M9"YB86YD=VED=&@@/2`H,C`P,"`J(#$N,#0X-3AE*S`V*3L*+RH at 0V]M<&]U
M;F0@("`@*B\@("!]"B\J($)A8VME;F0@("`@("HO('-T871I8R!V;VED(%9#
M3%]B86-K96YD7V-H870@*'9O:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO
M*B!!8W1I;VX@("`@("`J+R`@(&)A8VME;F0N:7`@25!,(%L*72!)4$P*"B\J
M($%C=&EO;B`@("`@("HO("`@8F%C:V5N9"YT:6UE;W5T(#T@*#0@*B`Q*3L*
M+RH at 06-T:6]N("`@("`@*B\@("!B86-K96YD+F)A;F1W:61T:"`]("@R,#`P
M("H@,2XP-#@U.&4K,#8I.PHO*B!#;VUP;W5N9"`@("`J+R`@('T*+RH at 1G5N
M8W1I;VX@("`@*B\@<W1A=&EC('9O:60 at 5D-,7V9U;F-T:6]N7V)A:6P@*'9O
M:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO*B!!8W1I;VX@("`@("`J+R`@
M(%9#3%]E<G)O<B at T,#0L(")"86EL:6YG(&]U="(I.PHO*B!!8W1I;VX@("`@
M("`J+R`@(')E='5R;CL*+RH at 0V]M<&]U;F0@("`@*B\@("!]"B\J($9U;F-T
M:6]N("`@("HO('-T871I8R!V;VED(%9#3%]F=6YC=&EO;E]F971C:%]P;VQI
M8WD@*'9O:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO*B!)9E-T;70@("`@
M("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD7S`@
M("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*`HO
M*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7U-T<FEN9R`J
M+R`@("`@("`@("`@("!S=')I;F=?;6%T8V at H<F5Q+G5R;"YH;W-T+"`B+W9G
M+FYO)"\B*0HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*0HO*B!#;VYD
M7S$@("`@("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@
M*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N9"`@("`J+R`@
M("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@<F5Q+F)A8VME;F0@"B\J($-O
M;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@96QS92`*
M+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@
M(%9#3%]E<G)O<B at T,#0L($Y53$PI.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@
M?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@
M("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@
M("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO
M*B!#;VYD7TEN="`@("`J+R`@("`@("`@("`@("!B86-K96YD+G)E<W!O;G-E
M7W1I;64@/B`H,B`J(#$I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I
M"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J
M+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD
M("`@("HO("`@("!["B\J($EF4W1M="`@("`@("HO("`@("!I9B`*+RH at 0V]N
M9&ET:6]N86P@*B\@("`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`@
M("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%\R("`@
M("`@*B\@("`@("`@("`@("`@*`HO*B!#;VYD7U-T<FEN9R`J+R`@("`@("`@
M("`@("`@('-T<FEN9U]M871C:"AR97$N=7)L+G!A=&@L("(O;&%N9&)R=6=S
M<')I<V5R+R(I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`@("D*+RH@
M0V]N9%\Q("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@
M("`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`@("D*+RH at 0V]M<&]U
M;F0@("`@*B\@("`@("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@("!60TQ?
M9G5N8W1I;VY?8F%I;"@I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@("!]"B\J
M($-O;7!O=6YD("`@("HO("`@("!]"B\J($%C=&EO;B`@("`@("HO("`@5D-,
M7V9E=&-H*"D["B\J($EF4W1M="`@("`@("HO("`@:68@"B\J($-O;F1I=&EO
M;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@
M("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I
M"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@
M("!["B\J($EF4W1M="`@("`@("HO("`@("!I9B`*+RH at 0V]N9&ET:6]N86P@
M*B\@("`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`@("@*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@("`@
M("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@("`I"B\J
M($-O;F1?,2`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("`@*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@("`I"B\J($-O;7!O
M=6YD("`@("HO("`@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@("`@;V)J
M+G1T;"`K/2`H,3`@*B`V,"D["B\J($%C=&EO;B`@("`@("HO("`@("`@(')E
M='5R;CL*+RH at 0V]M<&]U;F0@("`@*B\@("`@("`@?0HO*B!!8W1I;VX@("`@
M("`J+R`@("`@5D-,7W-W:71C:%]C;VYF:6<H(F]H:'-H:70B*3L*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!I9B`*+RH@
M0V]N9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@
M*`HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@
M*B\@("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@
M;V)J+G)E<W5L="`]/2`T,#0@"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@
M("`I"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@
M("`J+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O
M=6YD("`@("HO("`@("!["B\J($%C=&EO;B`@("`@("HO("`@("!60TQ?97)R
M;W(H,S`P+"`B:'1T<#HO+W=W=RYV9RYN;R(I.PHO*B!#;VUP;W5N9"`@("`J
M+R`@("`@?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA
M;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@
M("`@*`HO*B!#;VYD7TEN="`@("`J+R`@("`@("`@("`@("!O8FHN<F5S=6QT
M("$](#(P,"`*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@
M("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@
M("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(')E='5R;CL*+RH at 0V]M<&]U
M;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!I9B`*+RH at 0V]N
M9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*`HO
M*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@
M("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@;V)J
M+G-I>F4@/B`H,C4V("H@,3`R-"D*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@
M("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@
M("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(%9#3%]N
M;U]C86-H92 at I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!)9E-T;70@
M("`@("`J+R`@(&5L<V4@:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J
M($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@
M("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?
M26YT("`@("HO("`@("`@("`@("`@(&]B:BYS:7IE(#X@*#,R("H@,3`R-"D*
M+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@
M*B\@("`@("`@("`I("8F("@*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@
M("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@;V)J+G1T;"`\("@R
M("H at -C`I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I
M"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@
M("!["B\J($%C=&EO;B`@("`@("HO("`@("!O8FHN='1L(#T@*#4@*B`V,"D[
M"B\J($-O;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@
M:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?
M,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?26YT("`@("HO("`@("`@
M("`@("`@(&)A8VME;F0N<F5S<&]N<V5?=&EM92`^("@R("H@,2D*+RH at 0V]N
M9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@
M("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N
M86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N
M("`@("`@*B\@("`@(&]B:BYT=&P@*CT at .PHO*B!#;VUP;W5N9"`@("`J+R`@
M("`@?0HO*B!#;VUP;W5N9"`@("`J+R`@('T*+RH at 1G5N8W1I;VX@("`@*B\@
M<W1A=&EC('9O:60 at 5D-,7V9U;F-T:6]N7W!R969E=&-H7W!O;&EC>2`H=F]I
M9"D*+RH at 0V]M<&]U;F0@("`@*B\@("!["B\J($EF4W1M="`@("`@("HO("`@
M:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?
M,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?26YT("`@("HO("`@("`@
M("`@("`@(&]B:BYU<V%G92`\(#$P(`HO*B!#;VYD7S(@("`@("`J+R`@("`@
M("`@("`@*0HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("D@)B8@*`HO*B!#
M;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@("`J+R`@
M("`@("`@("`@("!O8FHN='1L(#P@*#4@*B`V,"D*+RH at 0V]N9%\R("`@("`@
M*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J
M($-O;F1?,"`@("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@
M("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@
M("`@(%9#3%]F971C:"@I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!#
2;VUP;W5N9"`@("`J+R`@('T*
`
end


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
... is moving nicely along.

I have made some changes to the syntax relative to what we talked
about at the meeting, mostly in order to be able to make the compiler
simpler and to give better error messages.

First of all, I have given all actions a trailing semi-colon.
In case of syntax errors, that will stop the compiler from trying to
make sense of subsequent tokens and that will hopefully limit the
amount of non-sense errors emitted in that case.

I have also decided that all assignments will start out with the
keyword "set".

Finally I have decided to enforce proper types and units throughout,
so if you compare a time variable, you must specify the units:

if (obj.ttl < 10m)

etc.

I have added explicit backend declarations:

backend vg {
set backend.ip = 10.0.0.1, 10.0.0.2, 10.0.0.3;
set backend.timeout = 4s;
set backend.bandwidth = 2000Mb/s;
}

because we need a data structure for each backend.

And this gets me to the something which is a sticky point right
now: IP numbers and IP lists.

With respect to backends, I think we need to declare them individually
because things like response time etc is per backend and not shared
for the cluster of backends. In the above example that would
restrict us to giving one IP#. (We can later expand this to a
concept of backend clusters but I need time to think about data structures
before I make up my mind.

The other thing is matching against IP lists, I think from both a code
and configuration point of view it makes sense to declare IP access lists
explicitly, so that instead of

if (client.ip ~ {10.0.0.0/8,172.16.0,0/12,192.168.0.0/16}) { ...

it would be written

Acl Rfc1918 {
10.0.0.0/8
172.16.0.0/12
192.168.0.0/16
}
...

if (client.ip ~ rfc1918) { ...

But I would still allow comparison to a single IP:

if (client.ip = 10.0.1.2) { ...

Still thinking about this though...

The compiler so far is 900 lines of C-code and a 170 line tcl script
to generate some C-code for keyword recognition.

Attached a sample config file and the compiled output as it
looks right now:

begin 664 sample.vcl
M"G-U8B!R97%U97-T7W!O;&EC>2!["@H):68@*&-L:65N="YI<"!^(#$P+C`N
M,"XP+S at I('L*"0EN;U]C86-H93L*"0EF:6YI<V@["@E]"@H):68@*')E<2YU
M<FPN:&]S="!^(")C;FXN;F\D(BD@>PH)"7)E=W)I=&4@(F-N;BYN;R0B(")V
M9RYN;R(["@E]"@H):68@*')E<2YU<FPN<&%T:"!^(")C9VDM8FEN(BD@>PH)
M"6YO7V-A8VAE.PH)?0H*"6EF("AR97$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YD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@
M("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`I)4$P at 6PI=($E0
M3`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*0HO*B!#;VYD7S$@("`@
M("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*0HO*B!#
M;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N9"`@("`J+R`@("`@>PHO
M*B!!8W1I;VX@("`@("`J+R`@("`@5D-,7VYO7V-A8VAE*"D["B\J($%C=&EO
M;B`@("`@("HO("`@("!R971U<FX["B\J($-O;7!O=6YD("`@("HO("`@("!]
M"B\J($EF4W1M="`@("`@("HO("`@:68@"B\J($-O;F1I=&EO;F%L("HO("`@
M("`H"B\J($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N9%\Q("`@("`@
M*B\@("`@("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`H"B\J
M($-O;F1?4W1R:6YG("HO("`@("`@("`@("`@('-T<FEN9U]M871C:"AR97$N
M=7)L+FAO<W0L(")C;FXN;F\D(BD*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@
M("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@
M("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(%9#3%]R
M97=R:71E*")C;FXN;F\D(BPL(")V9RYN;R(I.PHO*B!#;VUP;W5N9"`@("`J
M+R`@("`@?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA
M;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@
M("`@*`HO*B!#;VYD7U-T<FEN9R`J+R`@("`@("`@("`@("!S=')I;F=?;6%T
M8V at H<F5Q+G5R;"YP871H+"`B8V=I+6)I;B(I"B\J($-O;F1?,B`@("`@("HO
M("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#
M;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I
M"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J($%C=&EO;B`@("`@("HO("`@
M("!60TQ?;F]?8V%C:&4H*3L*+RH at 0V]M<&]U;F0@("`@*B\@("`@('T*+RH@
M2693=&UT("`@("`@*B\@("!I9B`*+RH at 0V]N9&ET:6]N86P@*B\@("`@("@*
M+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*`HO*B!#;VYD7S$@("`@("`J+R`@
M("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N
M9%]3=')I;F<@*B\@("`@("`@("`@("`@<W1R:6YG7VUA=&-H*')E<2YU<V5R
M86=E;G0L(")S<&ED97(B*0HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@
M*0HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@
M*B\@("`@("`@*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N
M9"`@("`J+R`@("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@5D-,7VYO7VYE
M=U]C86-H92 at I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!)9E-T;70@
M("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD
M7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@
M*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@
M("`J+R`@("`@("`@("`@("!B86-K96YD+G)E<W!O;G-E7W1I;64@/B`H,"XX
M("H@,2D*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q
M("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@("D*
M+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@
M('L*+RH at 06-T:6]N("`@("`@*B\@("`@(')E<2YT=&QF86-T;W(@/2`Q+C4[
M"B\J($-O;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@
M96QS92!I9B`*+RH at 0V]N9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@
M("`@*B\@("`@("`@*`HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH@
M0V]N9%\R("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@
M("`@("`@("`@("`@8F%C:V5N9"YR97-P;VYS95]T:6UE(#X@*#$N-2`J(#$I
M"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@
M("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O
M;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J
M($%C=&EO;B`@("`@("HO("`@("!R97$N='1L9F%C=&]R(#T@,CL*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!E;'-E(&EF
M(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@
M("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@
M("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@("`J+R`@("`@("`@
M("`@("!B86-K96YD+G)E<W!O;G-E7W1I;64@/B`H,BXU("H at -C`I"B\J($-O
M;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,2`@("`@("HO("`@
M("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I"B\J($-O;F1I=&EO
M;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@("!["B\J($%C=&EO
M;B`@("`@("HO("`@("!R97$N='1L9F%C=&]R(#T at -3L*+RH at 0V]M<&]U;F0@
M("`@*B\@("`@('T*+RH at 0V]M<&]U;F0@("`@*B\@("!]"B\J($)A8VME;F0@
M("`@("HO('-T871I8R!V;VED(%9#3%]B86-K96YD7W9G("AV;VED*0HO*B!#
M;VUP;W5N9"`@("`J+R`@('L*+RH at 06-T:6]N("`@("`@*B\@("!B86-K96YD
M+FEP($E03"!;"ET at 25!,"@HO*B!!8W1I;VX@("`@("`J+R`@(&)A8VME;F0N
M=&EM96]U="`]("@T("H@,2D["B\J($%C=&EO;B`@("`@("HO("`@8F%C:V5N
M9"YB86YD=VED=&@@/2`H,C`P,"`J(#$N,#0X-3AE*S`V*3L*+RH at 0V]M<&]U
M;F0@("`@*B\@("!]"B\J($)A8VME;F0@("`@("HO('-T871I8R!V;VED(%9#
M3%]B86-K96YD7V-H870@*'9O:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO
M*B!!8W1I;VX@("`@("`J+R`@(&)A8VME;F0N:7`@25!,(%L*72!)4$P*"B\J
M($%C=&EO;B`@("`@("HO("`@8F%C:V5N9"YT:6UE;W5T(#T@*#0@*B`Q*3L*
M+RH at 06-T:6]N("`@("`@*B\@("!B86-K96YD+F)A;F1W:61T:"`]("@R,#`P
M("H@,2XP-#@U.&4K,#8I.PHO*B!#;VUP;W5N9"`@("`J+R`@('T*+RH at 1G5N
M8W1I;VX@("`@*B\@<W1A=&EC('9O:60 at 5D-,7V9U;F-T:6]N7V)A:6P@*'9O
M:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO*B!!8W1I;VX@("`@("`J+R`@
M(%9#3%]E<G)O<B at T,#0L(")"86EL:6YG(&]U="(I.PHO*B!!8W1I;VX@("`@
M("`J+R`@(')E='5R;CL*+RH at 0V]M<&]U;F0@("`@*B\@("!]"B\J($9U;F-T
M:6]N("`@("HO('-T871I8R!V;VED(%9#3%]F=6YC=&EO;E]F971C:%]P;VQI
M8WD@*'9O:60I"B\J($-O;7!O=6YD("`@("HO("`@>PHO*B!)9E-T;70@("`@
M("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@("`@*`HO*B!#;VYD7S`@
M("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*`HO
M*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7U-T<FEN9R`J
M+R`@("`@("`@("`@("!S=')I;F=?;6%T8V at H<F5Q+G5R;"YH;W-T+"`B+W9G
M+FYO)"\B*0HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*0HO*B!#;VYD
M7S$@("`@("`J+R`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@
M*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@*0HO*B!#;VUP;W5N9"`@("`J+R`@
M("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@<F5Q+F)A8VME;F0@"B\J($-O
M;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@96QS92`*
M+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@
M(%9#3%]E<G)O<B at T,#0L($Y53$PI.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@
M?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA;"`J+R`@
M("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?,2`@("`@
M("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO
M*B!#;VYD7TEN="`@("`J+R`@("`@("`@("`@("!B86-K96YD+G)E<W!O;G-E
M7W1I;64@/B`H,B`J(#$I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I
M"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J
M+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD
M("`@("HO("`@("!["B\J($EF4W1M="`@("`@("HO("`@("!I9B`*+RH at 0V]N
M9&ET:6]N86P@*B\@("`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`@
M("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%\R("`@
M("`@*B\@("`@("`@("`@("`@*`HO*B!#;VYD7U-T<FEN9R`J+R`@("`@("`@
M("`@("`@('-T<FEN9U]M871C:"AR97$N=7)L+G!A=&@L("(O;&%N9&)R=6=S
M<')I<V5R+R(I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`@("D*+RH@
M0V]N9%\Q("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\P("`@("`@*B\@
M("`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`@("D*+RH at 0V]M<&]U
M;F0@("`@*B\@("`@("`@>PHO*B!!8W1I;VX@("`@("`J+R`@("`@("!60TQ?
M9G5N8W1I;VY?8F%I;"@I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@("!]"B\J
M($-O;7!O=6YD("`@("HO("`@("!]"B\J($%C=&EO;B`@("`@("HO("`@5D-,
M7V9E=&-H*"D["B\J($EF4W1M="`@("`@("HO("`@:68@"B\J($-O;F1I=&EO
M;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@
M("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I
M"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@
M("!["B\J($EF4W1M="`@("`@("HO("`@("!I9B`*+RH at 0V]N9&ET:6]N86P@
M*B\@("`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`@("@*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@("`@
M("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@("`@("`I"B\J
M($-O;F1?,2`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("`@*0HO*B!#;VYD:71I;VYA;"`J+R`@("`@("`I"B\J($-O;7!O
M=6YD("`@("HO("`@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@("`@;V)J
M+G1T;"`K/2`H,3`@*B`V,"D["B\J($%C=&EO;B`@("`@("HO("`@("`@(')E
M='5R;CL*+RH at 0V]M<&]U;F0@("`@*B\@("`@("`@?0HO*B!!8W1I;VX@("`@
M("`J+R`@("`@5D-,7W-W:71C:%]C;VYF:6<H(F]H:'-H:70B*3L*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!I9B`*+RH@
M0V]N9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@
M*`HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@
M*B\@("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@
M;V)J+G)E<W5L="`]/2`T,#0@"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@
M("`I"B\J($-O;F1?,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@
M("`J+R`@("`@("`I"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O
M=6YD("`@("HO("`@("!["B\J($%C=&EO;B`@("`@("HO("`@("!60TQ?97)R
M;W(H,S`P+"`B:'1T<#HO+W=W=RYV9RYN;R(I.PHO*B!#;VUP;W5N9"`@("`J
M+R`@("`@?0HO*B!)9E-T;70@("`@("`J+R`@(&EF(`HO*B!#;VYD:71I;VYA
M;"`J+R`@("`@*`HO*B!#;VYD7S`@("`@("`J+R`@("`@("`H"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*`HO*B!#;VYD7S(@("`@("`J+R`@("`@("`@
M("`@*`HO*B!#;VYD7TEN="`@("`J+R`@("`@("`@("`@("!O8FHN<F5S=6QT
M("$](#(P,"`*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N
M9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@
M("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@
M("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(')E='5R;CL*+RH at 0V]M<&]U
M;F0@("`@*B\@("`@('T*+RH at 2693=&UT("`@("`@*B\@("!I9B`*+RH at 0V]N
M9&ET:6]N86P@*B\@("`@("@*+RH at 0V]N9%\P("`@("`@*B\@("`@("`@*`HO
M*B!#;VYD7S$@("`@("`J+R`@("`@("`@("@*+RH at 0V]N9%\R("`@("`@*B\@
M("`@("`@("`@("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@;V)J
M+G-I>F4@/B`H,C4V("H@,3`R-"D*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@
M("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J($-O;F1?,"`@
M("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@("D*+RH at 0V]M
M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@("`@(%9#3%]N
M;U]C86-H92 at I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!)9E-T;70@
M("`@("`J+R`@(&5L<V4@:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J
M($-O;F1?,"`@("`@("HO("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@
M("`@("`H"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?
M26YT("`@("HO("`@("`@("`@("`@(&]B:BYS:7IE(#X@*#,R("H@,3`R-"D*
M+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@
M*B\@("`@("`@("`I("8F("@*+RH at 0V]N9%\R("`@("`@*B\@("`@("`@("`@
M("@*+RH at 0V]N9%]);G0@("`@*B\@("`@("`@("`@("`@;V)J+G1T;"`\("@R
M("H at -C`I"B\J($-O;F1?,B`@("`@("HO("`@("`@("`@("`I"B\J($-O;F1?
M,2`@("`@("HO("`@("`@("`@*0HO*B!#;VYD7S`@("`@("`J+R`@("`@("`I
M"B\J($-O;F1I=&EO;F%L("HO("`@("`I"B\J($-O;7!O=6YD("`@("HO("`@
M("!["B\J($%C=&EO;B`@("`@("HO("`@("!O8FHN='1L(#T@*#4@*B`V,"D[
M"B\J($-O;7!O=6YD("`@("HO("`@("!]"B\J($EF4W1M="`@("`@("HO("`@
M:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?
M,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?26YT("`@("HO("`@("`@
M("`@("`@(&)A8VME;F0N<F5S<&]N<V5?=&EM92`^("@R("H@,2D*+RH at 0V]N
M9%\R("`@("`@*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@
M("`@("`I"B\J($-O;F1?,"`@("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N
M86P@*B\@("`@("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N
M("`@("`@*B\@("`@(&]B:BYT=&P@*CT at .PHO*B!#;VUP;W5N9"`@("`J+R`@
M("`@?0HO*B!#;VUP;W5N9"`@("`J+R`@('T*+RH at 1G5N8W1I;VX@("`@*B\@
M<W1A=&EC('9O:60 at 5D-,7V9U;F-T:6]N7W!R969E=&-H7W!O;&EC>2`H=F]I
M9"D*+RH at 0V]M<&]U;F0@("`@*B\@("!["B\J($EF4W1M="`@("`@("HO("`@
M:68@"B\J($-O;F1I=&EO;F%L("HO("`@("`H"B\J($-O;F1?,"`@("`@("HO
M("`@("`@("@*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`H"B\J($-O;F1?
M,B`@("`@("HO("`@("`@("`@("`H"B\J($-O;F1?26YT("`@("HO("`@("`@
M("`@("`@(&]B:BYU<V%G92`\(#$P(`HO*B!#;VYD7S(@("`@("`J+R`@("`@
M("`@("`@*0HO*B!#;VYD7S$@("`@("`J+R`@("`@("`@("D@)B8@*`HO*B!#
M;VYD7S(@("`@("`J+R`@("`@("`@("`@*`HO*B!#;VYD7TEN="`@("`J+R`@
M("`@("`@("`@("!O8FHN='1L(#P@*#4@*B`V,"D*+RH at 0V]N9%\R("`@("`@
M*B\@("`@("`@("`@("D*+RH at 0V]N9%\Q("`@("`@*B\@("`@("`@("`I"B\J
M($-O;F1?,"`@("`@("HO("`@("`@("D*+RH at 0V]N9&ET:6]N86P@*B\@("`@
M("D*+RH at 0V]M<&]U;F0@("`@*B\@("`@('L*+RH at 06-T:6]N("`@("`@*B\@
M("`@(%9#3%]F971C:"@I.PHO*B!#;VUP;W5N9"`@("`J+R`@("`@?0HO*B!#
2;VUP;W5N9"`@("`J+R`@('T*
`
end


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> Finally I have decided to enforce proper types and units throughout,
> so if you compare a time variable, you must specify the units:
>
> if (obj.ttl < 10m)

Excellent. I thought about this, but forgot to mention it. It gives
us all the advantages of Hungarian notation without any of the
disadvantages (such as having to use Hungarian notation) :)

> The compiler so far is 900 lines of C-code and a 170 line tcl script
> to generate some C-code for keyword recognition.

I imagine the Tcl script will be replaced with lex/yacc at some point?

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> Finally I have decided to enforce proper types and units throughout,
> so if you compare a time variable, you must specify the units:
>
> if (obj.ttl < 10m)

Excellent. I thought about this, but forgot to mention it. It gives
us all the advantages of Hungarian notation without any of the
disadvantages (such as having to use Hungarian notation) :)

> The compiler so far is 900 lines of C-code and a 170 line tcl script
> to generate some C-code for keyword recognition.

I imagine the Tcl script will be replaced with lex/yacc at some point?

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
In message <ujrmzfyfs1o.fsf at cat.linpro.no>, Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= writes:
>"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
>> Finally I have decided to enforce proper types and units throughout,
>> so if you compare a time variable, you must specify the units:
>>
>> if (obj.ttl < 10m)
>
>Excellent. I thought about this, but forgot to mention it. It gives
>us all the advantages of Hungarian notation without any of the
>disadvantages (such as having to use Hungarian notation) :)

:-)

>> The compiler so far is 900 lines of C-code and a 170 line tcl script
>> to generate some C-code for keyword recognition.
>
>I imagine the Tcl script will be replaced with lex/yacc at some point?

My plan was to run the tcl script by hand and check both the script
and the result into the tree.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
In message <ujrmzfyfs1o.fsf at cat.linpro.no>, Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= writes:
>"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
>> Finally I have decided to enforce proper types and units throughout,
>> so if you compare a time variable, you must specify the units:
>>
>> if (obj.ttl < 10m)
>
>Excellent. I thought about this, but forgot to mention it. It gives
>us all the advantages of Hungarian notation without any of the
>disadvantages (such as having to use Hungarian notation) :)

:-)

>> The compiler so far is 900 lines of C-code and a 170 line tcl script
>> to generate some C-code for keyword recognition.
>
>I imagine the Tcl script will be replaced with lex/yacc at some point?

My plan was to run the tcl script by hand and check both the script
and the result into the tree.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> Dag-Erling Sm?rgrav?= writes:
> > I imagine the Tcl script will be replaced with lex/yacc at some point?
> My plan was to run the tcl script by hand and check both the script
> and the result into the tree.

OK. We can convert it to lex/yacc at some later date - as long as Tcl
does not become a build dependency.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> Dag-Erling Sm?rgrav?= writes:
> > I imagine the Tcl script will be replaced with lex/yacc at some point?
> My plan was to run the tcl script by hand and check both the script
> and the result into the tree.

OK. We can convert it to lex/yacc at some later date - as long as Tcl
does not become a build dependency.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
In message <ujrlkvilck8.fsf at cat.linpro.no>, Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= writes:
>"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
>> Dag-Erling Sm=F8rgrav?=3D writes:
>> > I imagine the Tcl script will be replaced with lex/yacc at some point?
>> My plan was to run the tcl script by hand and check both the script
>> and the result into the tree.
>
>OK. We can convert it to lex/yacc at some later date - as long as Tcl
>does not become a build dependency.

lex/yacc would be a major pain in this context.

It would be easier to convert the tcl script to
$some_other_scripting_language instead of tcl.

But for now, don't sweat it, tcl will not be a build dependency.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
In message <ujrlkvilck8.fsf at cat.linpro.no>, Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= writes:
>"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
>> Dag-Erling Sm=F8rgrav?=3D writes:
>> > I imagine the Tcl script will be replaced with lex/yacc at some point?
>> My plan was to run the tcl script by hand and check both the script
>> and the result into the tree.
>
>OK. We can convert it to lex/yacc at some later date - as long as Tcl
>does not become a build dependency.

lex/yacc would be a major pain in this context.

It would be easier to convert the tcl script to
$some_other_scripting_language instead of tcl.

But for now, don't sweat it, tcl will not be a build dependency.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
>
> ... is moving nicely along.
>
> I have made some changes to the syntax relative to what we talked
> about at the meeting, mostly in order to be able to make the compiler
> simpler and to give better error messages.

I have no objections to any of the changes. In fact I find working with
ACL's and "strict" configurations good. It may take some more time to
configure, but the gain is that it is easy to debug from a sys.adm point
of view and easier for people from the "outside" to see what you have
done.
Also it tends to be accurate in the sense that with "strict" notations,
you more seldom experience "Wow, I thought I did something else there".

Anders Berg

> First of all, I have given all actions a trailing semi-colon.
> In case of syntax errors, that will stop the compiler from trying to
> make sense of subsequent tokens and that will hopefully limit the
> amount of non-sense errors emitted in that case.
>
> I have also decided that all assignments will start out with the
> keyword "set".
>
> Finally I have decided to enforce proper types and units throughout,
> so if you compare a time variable, you must specify the units:
>
> if (obj.ttl < 10m)
>
> etc.
>
> I have added explicit backend declarations:
>
> backend vg {
> set backend.ip = 10.0.0.1, 10.0.0.2, 10.0.0.3;
> set backend.timeout = 4s;
> set backend.bandwidth = 2000Mb/s;
> }
>
> because we need a data structure for each backend.
>
> And this gets me to the something which is a sticky point right
> now: IP numbers and IP lists.
>
> With respect to backends, I think we need to declare them individually
> because things like response time etc is per backend and not shared
> for the cluster of backends. In the above example that would
> restrict us to giving one IP#. (We can later expand this to a
> concept of backend clusters but I need time to think about data structures
> before I make up my mind.
>
> The other thing is matching against IP lists, I think from both a code
> and configuration point of view it makes sense to declare IP access lists
> explicitly, so that instead of
>
> if (client.ip ~ {10.0.0.0/8,172.16.0,0/12,192.168.0.0/16}) { ...
>
> it would be written
>
> Acl Rfc1918 {
> 10.0.0.0/8
> 172.16.0.0/12
> 192.168.0.0/16
> }
> ...
>
> if (client.ip ~ rfc1918) { ...
>
> But I would still allow comparison to a single IP:
>
> if (client.ip = 10.0.1.2) { ...
>
> Still thinking about this though...
>
> The compiler so far is 900 lines of C-code and a 170 line tcl script
> to generate some C-code for keyword recognition.
>
> Attached a sample config file and the compiled output as it
> looks right now:
>
> --
> Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
> phk at FreeBSD.ORG | TCP/IP since RFC 956
> FreeBSD committer | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by
> incompetence.
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-dev
>
>
This VCL compiler thing... [ In reply to ]
>
> ... is moving nicely along.
>
> I have made some changes to the syntax relative to what we talked
> about at the meeting, mostly in order to be able to make the compiler
> simpler and to give better error messages.

I have no objections to any of the changes. In fact I find working with
ACL's and "strict" configurations good. It may take some more time to
configure, but the gain is that it is easy to debug from a sys.adm point
of view and easier for people from the "outside" to see what you have
done.
Also it tends to be accurate in the sense that with "strict" notations,
you more seldom experience "Wow, I thought I did something else there".

Anders Berg

> First of all, I have given all actions a trailing semi-colon.
> In case of syntax errors, that will stop the compiler from trying to
> make sense of subsequent tokens and that will hopefully limit the
> amount of non-sense errors emitted in that case.
>
> I have also decided that all assignments will start out with the
> keyword "set".
>
> Finally I have decided to enforce proper types and units throughout,
> so if you compare a time variable, you must specify the units:
>
> if (obj.ttl < 10m)
>
> etc.
>
> I have added explicit backend declarations:
>
> backend vg {
> set backend.ip = 10.0.0.1, 10.0.0.2, 10.0.0.3;
> set backend.timeout = 4s;
> set backend.bandwidth = 2000Mb/s;
> }
>
> because we need a data structure for each backend.
>
> And this gets me to the something which is a sticky point right
> now: IP numbers and IP lists.
>
> With respect to backends, I think we need to declare them individually
> because things like response time etc is per backend and not shared
> for the cluster of backends. In the above example that would
> restrict us to giving one IP#. (We can later expand this to a
> concept of backend clusters but I need time to think about data structures
> before I make up my mind.
>
> The other thing is matching against IP lists, I think from both a code
> and configuration point of view it makes sense to declare IP access lists
> explicitly, so that instead of
>
> if (client.ip ~ {10.0.0.0/8,172.16.0,0/12,192.168.0.0/16}) { ...
>
> it would be written
>
> Acl Rfc1918 {
> 10.0.0.0/8
> 172.16.0.0/12
> 192.168.0.0/16
> }
> ...
>
> if (client.ip ~ rfc1918) { ...
>
> But I would still allow comparison to a single IP:
>
> if (client.ip = 10.0.1.2) { ...
>
> Still thinking about this though...
>
> The compiler so far is 900 lines of C-code and a 170 line tcl script
> to generate some C-code for keyword recognition.
>
> Attached a sample config file and the compiled output as it
> looks right now:
>
> --
> Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
> phk at FreeBSD.ORG | TCP/IP since RFC 956
> FreeBSD committer | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by
> incompetence.
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at projects.linpro.no
> http://projects.linpro.no/mailman/listinfo/varnish-dev
>
>
This VCL compiler thing... [ In reply to ]
In message <1420.193.213.34.102.1142093353.squirrel at denise.vg.no>, "Anders Berg
" writes:

I know some people are quite religious about error messages, so here
are a couple of samples from the VCL compiler:


Unreferenced function 'request_policy', first mention is
Line 8 Pos 4
sub request_policy {
----##############--


Unknown variable 'obj.bandwidth'
At: Line 88 Pos 12
if (obj.bandwidth < 1 kb/h) {
------------#############------------


Assignments not possible for 'backend.down'
Line 88 Pos 25
set backend.down = 1;
-------------------------#---


Expected action, 'if' or '}'
Line 88 Pos 8
backend.down = 1;
--------############-----


Syntax error at
Line 80 Pos 13
fetch@;
-------------#-

Is that livable ?

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
In message <1420.193.213.34.102.1142093353.squirrel at denise.vg.no>, "Anders Berg
" writes:

I know some people are quite religious about error messages, so here
are a couple of samples from the VCL compiler:


Unreferenced function 'request_policy', first mention is
Line 8 Pos 4
sub request_policy {
----##############--


Unknown variable 'obj.bandwidth'
At: Line 88 Pos 12
if (obj.bandwidth < 1 kb/h) {
------------#############------------


Assignments not possible for 'backend.down'
Line 88 Pos 25
set backend.down = 1;
-------------------------#---


Expected action, 'if' or '}'
Line 88 Pos 8
backend.down = 1;
--------############-----


Syntax error at
Line 80 Pos 13
fetch@;
-------------#-

Is that livable ?

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> I know some people are quite religious about error messages, so here
> are a couple of samples from the VCL compiler:
>
>
> Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>
>
> Assignments not possible for 'backend.down'
> Line 88 Pos 25
> set backend.down = 1;
> -------------------------#---
>
>
> Expected action, 'if' or '}'
> Line 88 Pos 8
> backend.down = 1;
> --------############-----
>
>
> Syntax error at
> Line 80 Pos 13
> fetch@;
> -------------#-
>
> Is that livable ?

Good enough for government work. We can add a command-line option
later to generate editor-friendly error messages.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
"Poul-Henning Kamp" <phk at phk.freebsd.dk> writes:
> I know some people are quite religious about error messages, so here
> are a couple of samples from the VCL compiler:
>
>
> Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>
>
> Assignments not possible for 'backend.down'
> Line 88 Pos 25
> set backend.down = 1;
> -------------------------#---
>
>
> Expected action, 'if' or '}'
> Line 88 Pos 8
> backend.down = 1;
> --------############-----
>
>
> Syntax error at
> Line 80 Pos 13
> fetch@;
> -------------#-
>
> Is that livable ?

Good enough for government work. We can add a command-line option
later to generate editor-friendly error messages.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no
This VCL compiler thing... [ In reply to ]
They satisfy me.

Line, Pos and errortype.

If I am not mistaken getting more "humanreadable" error's is just a matter
of spending alot of time in the C code, without really changing the logic
of your parsercode and testing iteration after iteration? If that is the
case, I say move on :)

Anders Berg



At 10:43 13.03.2006 +0100, Poul-Henning Kamp wrote:
>In message <1420.193.213.34.102.1142093353.squirrel at denise.vg.no>, "Anders
>Berg
>" writes:
>
>I know some people are quite religious about error messages, so here
>are a couple of samples from the VCL compiler:
>
>
> Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>
>
> Assignments not possible for 'backend.down'
> Line 88 Pos 25
> set backend.down = 1;
> -------------------------#---
>
>
> Expected action, 'if' or '}'
> Line 88 Pos 8
> backend.down = 1;
> --------############-----
>
>
> Syntax error at
> Line 80 Pos 13
> fetch@;
> -------------#-
>
>Is that livable ?
>
>--
>Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
>phk at FreeBSD.ORG | TCP/IP since RFC 956
>FreeBSD committer | BSD since 4.3-tahoe
>Never attribute to malice what can adequately be explained by incompetence.
>_______________________________________________
>varnish-dev mailing list
>varnish-dev at projects.linpro.no
>http://projects.linpro.no/mailman/listinfo/varnish-dev




*****************************************************************
Denne fotnoten bekrefter at denne e-postmeldingen ble
skannet av MailSweeper og funnet fri for virus.
*****************************************************************
This footnote confirms that this email message has been swept by
MailSweeper for the presence of computer viruses.
*****************************************************************
This VCL compiler thing... [ In reply to ]
They satisfy me.

Line, Pos and errortype.

If I am not mistaken getting more "humanreadable" error's is just a matter
of spending alot of time in the C code, without really changing the logic
of your parsercode and testing iteration after iteration? If that is the
case, I say move on :)

Anders Berg



At 10:43 13.03.2006 +0100, Poul-Henning Kamp wrote:
>In message <1420.193.213.34.102.1142093353.squirrel at denise.vg.no>, "Anders
>Berg
>" writes:
>
>I know some people are quite religious about error messages, so here
>are a couple of samples from the VCL compiler:
>
>
> Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>
>
> Assignments not possible for 'backend.down'
> Line 88 Pos 25
> set backend.down = 1;
> -------------------------#---
>
>
> Expected action, 'if' or '}'
> Line 88 Pos 8
> backend.down = 1;
> --------############-----
>
>
> Syntax error at
> Line 80 Pos 13
> fetch@;
> -------------#-
>
>Is that livable ?
>
>--
>Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
>phk at FreeBSD.ORG | TCP/IP since RFC 956
>FreeBSD committer | BSD since 4.3-tahoe
>Never attribute to malice what can adequately be explained by incompetence.
>_______________________________________________
>varnish-dev mailing list
>varnish-dev at projects.linpro.no
>http://projects.linpro.no/mailman/listinfo/varnish-dev




*****************************************************************
Denne fotnoten bekrefter at denne e-postmeldingen ble
skannet av MailSweeper og funnet fri for virus.
*****************************************************************
This footnote confirms that this email message has been swept by
MailSweeper for the presence of computer viruses.
*****************************************************************
This VCL compiler thing... [ In reply to ]
In message <5.2.0.9.0.20060313104755.0339a8a8 at pop.vg.no>, Anders Berg writes:
>They satisfy me.
>
>Line, Pos and errortype.
>
>If I am not mistaken getting more "humanreadable" error's is just a matter
>of spending alot of time in the C code, without really changing the logic
>of your parsercode and testing iteration after iteration? If that is the
>case, I say move on :)

Yes, the actual errors are just a matter of printf calls.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
In message <5.2.0.9.0.20060313104755.0339a8a8 at pop.vg.no>, Anders Berg writes:
>They satisfy me.
>
>Line, Pos and errortype.
>
>If I am not mistaken getting more "humanreadable" error's is just a matter
>of spending alot of time in the C code, without really changing the logic
>of your parsercode and testing iteration after iteration? If that is the
>case, I say move on :)

Yes, the actual errors are just a matter of printf calls.

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
It also accured to me that we could link the errors to the error documentation.

Unreferenced function 'request_policy', first mention is
Line 8 Pos 4
sub request_policy {
----##############--
Read more about this type of error:
http://varnish/doc/error.html#Unreferenced%20function


Unknown variable 'obj.bandwidth'
At: Line 88 Pos 12
if (obj.bandwidth < 1 kb/h) {
------------#############------------
Read more about this type of error:
http://varnish/doc/error.html#Unknown%20variable


or something of the likes.
I think that is easy to implement and would help people that may be stuck.
Just throw in some links, so we will remember to document them later when
we see the errors.

Anders Berg


At 10:56 13.03.2006 +0100, Poul-Henning Kamp wrote:
>In message <5.2.0.9.0.20060313104755.0339a8a8 at pop.vg.no>, Anders Berg writes:
> >They satisfy me.
> >
> >Line, Pos and errortype.
> >
> >If I am not mistaken getting more "humanreadable" error's is just a matter
> >of spending alot of time in the C code, without really changing the logic
> >of your parsercode and testing iteration after iteration? If that is the
> >case, I say move on :)
>
>Yes, the actual errors are just a matter of printf calls.
>
>--
>Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
>phk at FreeBSD.ORG | TCP/IP since RFC 956
>FreeBSD committer | BSD since 4.3-tahoe
>Never attribute to malice what can adequately be explained by incompetence.




*****************************************************************
Denne fotnoten bekrefter at denne e-postmeldingen ble
skannet av MailSweeper og funnet fri for virus.
*****************************************************************
This footnote confirms that this email message has been swept by
MailSweeper for the presence of computer viruses.
*****************************************************************
This VCL compiler thing... [ In reply to ]
It also accured to me that we could link the errors to the error documentation.

Unreferenced function 'request_policy', first mention is
Line 8 Pos 4
sub request_policy {
----##############--
Read more about this type of error:
http://varnish/doc/error.html#Unreferenced%20function


Unknown variable 'obj.bandwidth'
At: Line 88 Pos 12
if (obj.bandwidth < 1 kb/h) {
------------#############------------
Read more about this type of error:
http://varnish/doc/error.html#Unknown%20variable


or something of the likes.
I think that is easy to implement and would help people that may be stuck.
Just throw in some links, so we will remember to document them later when
we see the errors.

Anders Berg


At 10:56 13.03.2006 +0100, Poul-Henning Kamp wrote:
>In message <5.2.0.9.0.20060313104755.0339a8a8 at pop.vg.no>, Anders Berg writes:
> >They satisfy me.
> >
> >Line, Pos and errortype.
> >
> >If I am not mistaken getting more "humanreadable" error's is just a matter
> >of spending alot of time in the C code, without really changing the logic
> >of your parsercode and testing iteration after iteration? If that is the
> >case, I say move on :)
>
>Yes, the actual errors are just a matter of printf calls.
>
>--
>Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
>phk at FreeBSD.ORG | TCP/IP since RFC 956
>FreeBSD committer | BSD since 4.3-tahoe
>Never attribute to malice what can adequately be explained by incompetence.




*****************************************************************
Denne fotnoten bekrefter at denne e-postmeldingen ble
skannet av MailSweeper og funnet fri for virus.
*****************************************************************
This footnote confirms that this email message has been swept by
MailSweeper for the presence of computer viruses.
*****************************************************************
This VCL compiler thing... [ In reply to ]
In message <5.2.0.9.0.20060313110024.033ffd78 at pop.vg.no>, Anders Berg writes:
>It also accured to me that we could link the errors to the error documentation.
>
>Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>Read more about this type of error:
>http://varnish/doc/error.html#Unreferenced%20function
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>Read more about this type of error:
>http://varnish/doc/error.html#Unknown%20variable

Good idea.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
In message <5.2.0.9.0.20060313110024.033ffd78 at pop.vg.no>, Anders Berg writes:
>It also accured to me that we could link the errors to the error documentation.
>
>Unreferenced function 'request_policy', first mention is
> Line 8 Pos 4
> sub request_policy {
> ----##############--
>Read more about this type of error:
>http://varnish/doc/error.html#Unreferenced%20function
>
>
> Unknown variable 'obj.bandwidth'
> At: Line 88 Pos 12
> if (obj.bandwidth < 1 kb/h) {
> ------------#############------------
>Read more about this type of error:
>http://varnish/doc/error.html#Unknown%20variable

Good idea.


--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
This VCL compiler thing... [ In reply to ]
Anders Berg <andersb at vg.no> writes:
> It also accured to me that we could link the errors to the error
> documentation. [...] I think that is easy to implement and would
> help people that may be stuck. Just throw in some links, so we will
> remember to document them later when we see the errors.

If Poul-Henning makes up a keyword for each type of error and places
the link in the error message, I'll write the documentation.

DES
--
Dag-Erling Sm?rgrav
Senior Software Developer
Linpro AS - www.linpro.no

1 2  View All