[ragel-users] A bug in Ragel?

Adrian Thurston thurs... at cs.queensu.ca
Sun May 6 20:50:25 UTC 2007


Hi Dinesh,

In the qualifier machine you've got '+-?'. This interpreted a range, not
as a union of three characters.

Cheers,
 Adrian

DinSoft wrote:
> Hello everyone,
> 
> I don't understand Ragel's behaviour on one point.
> Currently, I am implementing a parser for SPF (RFC 4408).
> 
> Everything was fine and working well but this.
> 
> Here is a snippet of the grammar rules in Ragel's syntax (full ABNF
> available at http://www.ietf.org/rfc/rfc4408.txt):
> 
>                 qualifier = ([+-?~]) >action_qualifier_1
> @action_qualifier_2;
> 
>                 all = ("all"i) >action_all_1 @action_all_2;
>                 version = ("v=spf1"i) >action_version_1
> @action_version_2;
> 
> 		name = (alpha ( alpha | digit | "-" | "_" | "." )*) >action_name_1
> @action_name_2;
> 
> 		redirect = ("redirect"i "=" domain_spec) >action_redirect_1
> @action_redirect_2;
> 		unknown_modifier = (name "=" macro_string)
>> action_unknown_modifier_1 @action_unknown_modifier_2;
> 		explanation = ("exp"i "=" domain_spec) >action_explanation_1
> @action_explanation_2;
> 
>                 mechanism = (all | include2 | A | MX | PTR | IP4 | IP6
> | exists) >action_mechanism_1 @action_mechanism_2;
> 		directive = ((qualifier)? mechanism) >action_directive_1
> @action_directive_2;
> 
> 		terms_spaces = ((' '){1,}) >action_terms_spaces_1
> @action_terms_spaces_2;
> 		terms_directive = (terms_spaces directive) >action_terms_directive_1
> @action_terms_directive_2;
> 		terms_modifier = (terms_spaces modifier) >action_terms_modifier_1
> @action_terms_modifier_2;
> 		terms = (( terms_directive | terms_modifier )*) >action_terms_1
> @action_terms_2;					# May be empty
> 
> 		record_spaces = ((' ')*) >action_record_spaces_1
> @action_record_spaces_2;						# May be empty
> 		record = (version terms record_spaces) >action_record_1
> @action_record_2;
> 
> 		# Language's starting rule
> 		main := record;
> 
> With the following user-action for qualifier:
>  		# qualifier
> 		action action_qualifier_1 {
> 			element.type = PARSE_ELEMENT_TYPE_QUALIFIER_START;
> 			element.start = fpc;
> 
> 			if (doubleLinkedListAddLast(&qualifier, element)) {
> 				goto atoi_error;
> 			}
> 		}
> 
> 		action action_qualifier_2 {
> 			element.type = PARSE_ELEMENT_TYPE_QUALIFIER_STOP;
> 			element.stop = fpc;
> 
> 			if (doubleLinkedListAddLast(&qualifier, element)) {
> 				goto atoi_error;
> 			}
> 		}
> 
> (all rule do have the same kind of user actions).
> 
> 
> Now I find amazing that, on the input "v=spf1 =all" , I am getting the
> '=' as being considered as a qualifier !
> 
> Here is the dump of my doubleLinkedList for qualifier:
> Parsing: v=spf1 =all!
> qualifier list: 2 elements in the list!
>         Start: 134729663 (=)
>         Stop: 134729663 (=)
> 
> When I go back to the rule of qualifier, I see:
>  qualifier = ([+-?~]) >action_qualifier_1 @action_qualifier_2;
> 
> So how is it possible that Ragel considers '=' as being a qualifier?
> 
> I was expecting a parse error (from the rule unknown_modifier ,
> because the rule "name" cannot be empty).
> 
> Thanks for your help !
> 
> Regards,
>  Dinesh Bolkensteyn
> 
> 
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070506/cdf3393e/attachment-0001.sig>


More information about the ragel-users mailing list