Minimisation question

Adrian Thurston thurs... at cs.queensu.ca
Fri Sep 15 19:27:48 UTC 2006


Hi Colin, thanks again for the grammar, it will be useful for optimizing Ragel.

This might be what you want:

action call_list {fcall list;}
action return {fret;}

item = word | '(' @call_list;

list := item (
             ( ',' item )* |
             ( '|' item )* )?
         ')' @return;
	
main := item;


Colin Fleming wrote:
> Sure, I've factored out the common rules, so I've attached a tar with
> the ASCII only and Unicode versions.
> 
> BTW I'd also be interested in any suggestions you can give me for
> replacing part of the grammar. Obviously XML is context free, mostly
> this is OK (I'm going to use the tag stack we discussed) but there's
> one section which is still giving me a headache.
> 
> It was like this (line 73 in xmlcommon.rl) :
> 
> cp = (Name | choice | seq) ('?' | '*' | '+')?;
> 
> seq = '(' S? cp ( S? ',' S? cp )* S? ')';
> 
> choice = '(' S? cp ( S? '|' S? cp )* S? ')';
> 
> children = (choice | seq) ('?' | '*' | '+')?;
> 
> I've just put in a dirty hack for now that will hopefully at least lex
> the construct more or less, but won't enforce any of the original
> grammar constraints. Any suggestions about how to do this gracefully
> would be great. I thought about using fcall but seq and choice are
> ambiguous after the opening parenthesis. I also thought about using
> the conditional trick in test/cond6.rl, but then it gets tricky making
> sure that it enforces sequences of only alternations or only
> concatenations (i.e. preventing ( a | b , c ). I really do need a
> stack of which symbol is used at what indentation level I think, but
> it's going to get a bit hairy.
> 
> Cheers,
> Colin
> 
> 
> 



More information about the ragel-users mailing list