Hi,

I'm trying to create RFC2822 parer but I'm having problem generating the code 
for some reason ragel keep running until I press CTRL C "was running for 20 
minutes", below
the grammar I'm trying to use.


%%{
        machine rfc2822_header;
        
        # Common ABNF rules
        cr                              = "\r";
        lf                              = "\n";
        crlf                            = cr lf;
        sp                              = " ";
        tab                             = "\t";
        wsp                             = (sp | tab);
        obs_fws                 = wsp+ ( crlf wsp+ )*;
        fws                             = ( ( wsp* crlf )? wsp+ ) | obs_fws;
        NO_WS_CTL       = 0x01..0x08 | "\v" | "\f" | 0x0e..0x1f | 0x7f;
        
        # Rules to consume comments
        consumeAny       = any - (")" | ")") | "(" @{fcall consumeComments;};
        consumeComments := consumeAny+ ")" $!{fhold; fret; };                   
        startComment     = "(" @{fcall consumeComments;};
        CFWS             = ( fws? startComment )* ( ( fws? startComment ) | fws 
); 

        ctext                   = NO_WS_CTL | 0x21..0x27 | 0x2a..0x5b;
        obs_char                = 0x00..0x09 | "\v" | "\f" | 0x0e..0x7f;
        obs_text                = "\n"* "\r"* ( obs_char "\n"* "\r"* )*;
        text                            = 0x01..0x09 | "\v" | "\f" | 0x0e..0x7f 
| obs_text;
        obs_qp                  = "\\" 0x00..0x7f;
        quoted_pair             = ( "\\" text ) | obs_qp;
        dtext                   = NO_WS_CTL | 0x21..0x5a;
        dcontent                = dtext | quoted_pair;
        
        atext                   = alpha | digit | "!" | "#" | "$" | "%" | "&" | 
"'" | "*" | "+" | "-" | "/" | "=" | "?" | "^" | "_" | "`" | "{" | "|" | "}" | 
"~";
        dot_atom_text   = atext+ ( "." atext+ )*;
        dot_atom                = CFWS? dot_atom_text CFWS?;
        qtext                   = NO_WS_CTL | "!" | 0x23..0x5b | 0x5d..0x7e;
        qcontent                = qtext | quoted_pair;
        quoted_string   = CFWS? "\"" ( fws? qcontent )* fws? "\"" CFWS?;
        atom                    = CFWS? atext+ CFWS?;
        word                    = atom | quoted_string;
        
        # Return-Path field.
        domain_literal  = CFWS? "[" ( fws? dcontent )* fws? "]" CFWS?;
        obs_domain              = atom ( "." atom )*;
        domain                  = dot_atom | domain_literal | obs_domain;
        obs_domain_list = "@" domain ( ( CFWS | "," )* CFWS? "@" domain )*;
        obs_route               = CFWS? obs_domain_list ":" CFWS?;
        obs_local_part  = word ( "." word )*;
        local_part              = dot_atom | quoted_string | obs_local_part;
        addr_spec               = local_part "@" domain;
        obs_angle_addr  = CFWS? "<" obs_route? addr_spec ">" CFWS?;
        obs_path                = obs_angle_addr;
        path                    = ( CFWS? "<" ( CFWS? | addr_spec ) ">" CFWS? ) 
| obs_path;
        obs_return              = "Return-Path" wsp* ":" path crlf;
        
        obs_fields       = obs_return;
        main            := obs_fields;
}%%

Thanks
_______________________________________________
ragel-users mailing list
[email protected]
http://www.complang.org/mailman/listinfo/ragel-users

Reply via email to