FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

enki question
Goto page Previous  1, 2
 
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries
View previous topic :: View next topic  
Author Message
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Jun 14, 2006 9:46 am    Post subject: Reply with quote

rko wrote:
nonsense i meant

ident ::= {'_'}('A'..'Z','a'..'z') {('A'..'Z','a'..'z','0'..'9')}255;


I plan on doing value ranges and iteration limits at some point in the future. I'll take your syntax examples under advisement - I might do something different though.

For now, you might want to provide those kinds of expressions as hard-coded parse functions similar to what I provided in BaseParser.d. In practice I've come to understand that range-based terminals are difficult to do optimally via a code generator - as such rules are so simple, manually coding them in is almost always the most efficent approach. Wink

Also, you can use regular expressions too by delimiting your expression using the back-tick (`).

Quote:
is there any way to sync to some rule or rulepart on error?


No. Enki's error reporting leaves much to be desired. I'm open to suggestions on how to improve it though. Any thoughts?
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Wed Jun 14, 2006 2:35 pm    Post subject: Reply with quote

Doesn't Enki support using regexp in a rule? If you need ranges of that sort, you might try writing the 'ident' rule as a simple regexp instead, the entire result of which could then be stored in an annotation pretty easily, I'd imagine. Can't recall the syntax for regexp in Enki though... I think its wrapped in backquotes. So something like:

Code:

ident = new Identifier(sym) ::= `^(_*[a-zA-Z][a-zA-Z0-9]*){0,255}`:sym ;


If it doesn't support this and I just saw it in a dream... then I dunno. ^__^
Keep in mind I'm no regexp wizard... so its surely far from perfect.
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
pragma



Joined: 28 May 2004
Posts: 607
Location: Washington, DC

PostPosted: Wed Jun 14, 2006 4:12 pm    Post subject: Reply with quote

csauls wrote:
Doesn't Enki support using regexp in a rule? If you need ranges of that sort, you might try writing the 'ident' rule as a simple regexp instead, the entire result of which could then be stored in an annotation pretty easily, I'd imagine. Can't recall the syntax for regexp in Enki though... I think its wrapped in backquotes. So something like:

Code:

ident = new Identifier(sym) ::= `^(_*[a-zA-Z][a-zA-Z0-9]*){0,255}`:sym ;


If it doesn't support this and I just saw it in a dream... then I dunno. ^__^
Keep in mind I'm no regexp wizard... so its surely far from perfect.


It supports them alright!

Edit: I think the correct expression is actually `([_a-zA-Z]+[_a-zA-Z0-9]*)`, but I'm not sure how you would use regex to calculate the length of the span/length of the outermost expression. I don't think this is possible outside of a hand-coded approach, or on a semantic pass after parsing. However, I do want Enki to be able to handle binary files in the future, so having a way to do such things in the grammar will become important.

Granted, I'm not a regex wizard either - and Walter's implementation in D, whlie useful, is really *bad* for getting single conservative matches out of an input. I whittled it down to as few lines as possible, but its anything but succinct.

(Straight from BaseParser.dSmile
Code:
   public ResultString regexp(String str){
      if (auto m = std.regexp.search(data[pos..$],str))
      {
         if(m.pre.length == 0){
            auto result = m.match(0);
            pos += result.length;
            return ResultString(result);
         }
      }
      return ResultString();
   }


One of these days I may have the courage to throw my/Don's template Regex at the problem, or even an Enki-generated regex engine - but not today.
_________________
-- !Eric.t.Anderton at gmail
Back to top
View user's profile Send private message Yahoo Messenger
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Wed Jun 14, 2006 5:45 pm    Post subject: Reply with quote

Quote:
or even an Enki-generated regex engine


Don't give me ideas! Wink
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DDL - D Dynamic Libraries All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group