[ragel-users] Ragel falls to infinite loop then actions are specified, and more questions about Ragel and ABNFGEN

Александр Мартынов amart at mail.ru
Wed Apr 10 05:58:08 UTC 2013


Hello Ragel-users,


 I try to create XML parser using abnfgen tool (http://www.2p.cz/en/abnf_gen/),
which I was found in the "Links" section on Ragel page (http://www.complang.org/ragel/).

 1) The main problem is that the Ragel falls to infinite loop, eats all available memory 
and cause the system message:

    "This application has requested the runtime to terminate it in unusual way.
    Please contact the application support team for more information."

when I try to add entering, leavint and "all transitions" actions to some machine.

This machine defines the Xml comment.
In ABNFGEN source I wrote:

    ANYCHAREXCEPTMINUS = %x01-2C / %x2C-FF
    XmlCommentText = *( (ANYCHAREXCEPTMINUS) / ("-" ANYCHAREXCEPTMINUS) )  ; - "-->"
    XmlComment  = "<!--" XmlCommentText "-->"

which produces next Ragel code:

    ANYCHAREXCEPTMINUS = 0x01..0x2c | 0x2c..0xff;
    XmlCommentText = ( ANYCHAREXCEPTMINUS | ( "-" ANYCHAREXCEPTMINUS ) )*;
    XmlComment = "<!--" XmlCommentText "-->";

The problem occurs when I try to add entering, leaving and "all transitions" 
actions to XmlCommentText (or XmlComment) machine/statement:

    XmlCommentText = ( ( ANYCHAREXCEPTMINUS | ( "-" ANYCHAREXCEPTMINUS ) )* )   >pfs_sax_parser_e_XmlCommentText    %pfs_sax_parser_l_XmlCommentText    $pfs_sax_parser_t_XmlCommentText;
    XmlComment = "<!--" XmlCommentText "-->";

In this case the Ragel fails. What I need to do here?

 2) Next question is about CData section, whis described in XML definition as:

    [18]    CDSect     ::=       CDStart CData CDEnd
    [19]    CDStart    ::=      '<![CDATA['
    [20]    CData      ::=      (Char* - (Char* ']]>' Char*))
    [21]    CDEnd      ::=      ']]>'

I can't understand, how to write BNF to ABNFGEN tool, or rule for Ragel both.

 3) The XML Element definition contains itself, and if I wrote exact

    XmlElement = XmlEmptyTag | ( XmlStartTag ( XmlCharData? ( ( XmlElement | XmlCommentOrPiOrCDataOrRef ) XmlCharData? )? ) XmlEndTag );

I got the message: graph lookup for 'XmlElement' failed.
I think I need to call submachine XmlElement, but I can't understand 
how and where I must do it, and where I need to return from submachine

 4) I was find that the Ragel generates invalid code, which can't be compiled with MSVC (but GCC can):

    ...
    if ( p == eof )
    {
    if ( _abnf_reader_eof_trans[cs] > 0 ) {
        _trans = _abnf_reader_eof_trans[cs] - 1;
        goto _eof_trans;
    }
    const char *__acts = _abnf_reader_actions + _abnf_reader_eof_actions[cs]; /* !!! */
    unsigned int __nacts = (unsigned int) *__acts++;
    while ( __nacts-- > 0 ) {
        switch ( *__acts++ ) {
    case 5:
    ...

MSVC fails on line marked with "!!!" with message 

    error C2143: syntax error : missing ';' before 'const'

I think occurs because variable __acts defined not at the block start, but after if statement.
How this problem can be solved?


  

________________________________________________
С уважением, Мартынов Александр (Marty)

mailto: amart at mail.ru


_______________________________________________
ragel-users mailing list
ragel-users at complang.org
http://www.complang.org/mailman/listinfo/ragel-users


More information about the ragel-users mailing list