Enki 1.1 Released

BCS BCS at pathlink.com
Wed Jun 14 14:14:37 PDT 2006


pragma wrote:
> In article <e6plq9$1upb$1 at digitaldaemon.com>, BCS says...
>>Cool, tried it out. Didn't get to far (I haven't used a parser generator 
>>before, so...). The generated parser still doesn't compile out of the 
>>box. I dug through the code and added a few imports to the render() 
>>function to get it to work. Here is a patch of what I did.
[...]
> 
> 
> BCS, thanks for being patient with all this.  I hope I haven't lost your
> interest. ;)

Nope, you have only wet it.

> 
> What you've done here is hack the code-generator to emit the imports you need -
> I like the cut of your jib.  As the documentation is incomplete, I can't blame
> you for trying this, but there is an easier way to do this.  The .import()
> directive does this job nicely.
> 
> 
>>.import("my.import.here");
> 

Are these imports not always needed? Won't any parser use things from 
these modules? I would think that the basic imports _should_ be hard 
coded (or at least implicitly added to the imports list).

On further thought only "enki.types" will _always_ be needed. 
"enki.BaseParser" will only be used if the default base class is used. 
But this is detectable, so again, it should be emitted unless the base 
class is changed.

> 
> A solid example of this and other directives are in Enki's BNF definition:
> 
> http://svn.dsource.org/projects/ddl/trunk/enki/enki.bnf
> 

I'll take closer a look at that soon.

========

And on another topic: another hack

It fixes a default case bug. Without it any rule of the form

rule ::= (foo bar)

always matches even if both foo and bar don't match. The case where the 
rule has annotations works as advertised.

<patch>
*** old\enki\Rule.d	Wed Jun 14 13:50:06 2006
--- new\enki\Rule.d	Wed Jun 14 13:50:59 2006
***************
*** 241,251 ****
   	}
   	
   	public void renderPass(CodeGenerator generator){
! 		generator.emit("return ResultT!(bool)(true);");
   	}
   	
   	public void renderFail(CodeGenerator generator){
! 		generator.emit("return ResultT!(bool)(false);");
   	}
   	
   	public void semanticPass(Rule thisRule,BaseEnkiParser root){
--- 242,252 ----
   	}
   	
   	public void renderPass(CodeGenerator generator){
! 		generator.emit("return ResultT!(bool)(true,true);");
   	}
   	
   	public void renderFail(CodeGenerator generator){
! 		generator.emit("return ResultT!(bool)(false,false);");
   	}
   	
   	public void semanticPass(Rule thisRule,BaseEnkiParser root){
</patch>



More information about the Digitalmars-d-announce mailing list