fcall legal in scanner?

Carlos Antunes cmantu... at gmail.com
Sun Oct 29 20:12:54 UTC 2006


Thanks, Adrian, your fix appears to be working fine. Oh, and I'll be
posting a feature request soon! :-)

On 10/29/06, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
>
> Indeed it will. 5.15 should be arriving soon.
>
> Cheers,
>   Adrian
>
> Carlos Antunes wrote:
> > Thanks, Adrian! Will this fix make it into 5.15?
> >
> > On 10/29/06, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> >> Hi Carlos,
> >>
> >> I found the bug. The problem was with fret in scanner actions. The
> >> adjustment to p that is needed in some cases was not happening. The
> >> attached patch will fix the problem.
> >>
> >> Cheers,
> >>   Adrian
> >>
> >> Carlos Antunes wrote:
> >>> On 10/27/06, Adrian Thurston <thurs... at cs.queensu.ca> wrote:
> >>>> It sounds like a bug. fcall is supposed to work in actions associated with
> >>>> entire patterns (the lex style actions) but they are illegal in the the
> >>>> transition/state based embeddings and Ragel is supposed to emit an error.
> >>>> Could you post or send me some code which exhibits the problem?
> >>>>
> >>> Adrian,
> >>>
> >>> Please, see test2.rl file attached. It's a messy file because it's
> >>> where I do, testing.
> >>>
> >>> Basically, I'm using a scanner (main) to match 'Organization',
> >>> 'Authorization' and a general purpose header called extension_header.
> >>> If there is a header like 'an-extension-header', the scanner should
> >>> match on the extension_header rule.
> >>>
> >>> Here's a string to match:
> >>>
> >>>             "Authorization: Digest username=\"Alice\",realm=\"atlanta.com\"\n"
> >>>             "    , response=\"7587245234b3434cc3412213e5f113a5432\" , \r\n"
> >>>             "    nonce=\"84a4cc6f3082121f32b42a2187831a9e\" \r\n"
> >>>             "Organization: Boxes by\r\n Bob  \r\n      \n"
> >>>             "An-Extension-Header: 10 \n"
> >>>             "\r\n";
> >>>
> >>> The scanner performs well with the previous string. Let's try a new string:
> >>>
> >>>             "An-Extension-Header: 10 \n"
> >>>             "Authorization: Digest username=\"Alice\",realm=\"atlanta.com\"\n"
> >>>             "    , response=\"7587245234b3434cc3412213e5f113a5432\" , \r\n"
> >>>             "    nonce=\"84a4cc6f3082121f32b42a2187831a9e\" \r\n"
> >>>             "Organization: Boxes by\r\n Bob  \r\n      \n"
> >>>             "\r\n";
> >>>
> >>> In this case, the scanner, once it matches the extension header, will
> >>> continue to match 'Authorization' and 'Organization' as extension
> >>> headers as well, which didn't happen before.
> >>>
> >>> Note that, if instead of using fcall from the main scanner, I use
> >>> fgoto (and them fgoto back to main instead of fret), both input
> >>> strings produce the same, and correct, behavior.
> >>>
> >>> Thanks!
> >>>
> >>> Carlos
> >>>
> >>
> >> Index: ragel/xmlcodegen.cpp
> >> ===================================================================
> >> --- ragel/xmlcodegen.cpp        (revision 3695)
> >> +++ ragel/xmlcodegen.cpp        (working copy)
> >> @@ -246,6 +246,9 @@
> >>         case InlineItem::Break:
> >>                 out << "<break></break>";
> >>                 break;
> >> +       case InlineItem::Ret:
> >> +               out << "<ret></ret>";
> >> +               break;
> >>         default: break;
> >>         }
> >>
> >> @@ -360,12 +363,9 @@
> >>                 case InlineItem::Goto: case InlineItem::GotoExpr:
> >>                 case InlineItem::Call: case InlineItem::CallExpr:
> >>                 case InlineItem::Next: case InlineItem::NextExpr:
> >> -               case InlineItem::Break:
> >> +               case InlineItem::Break: case InlineItem::Ret:
> >>                         writeWithContext( item, context );
> >>                         break;
> >> -               case InlineItem::Ret:
> >> -                       out << "<ret></ret>";
> >> -                       break;
> >>                 case InlineItem::PChar:
> >>                         out << "<pchar></pchar>";
> >>                         break;
> >>
> >>
> >>
> >
> >
>
> >
>


-- 
"We hold [...] that all men are created equal; that they are
endowed [...] with certain inalienable rights; that among
these are life, liberty, and the pursuit of happiness"
        -- Thomas Jefferson



More information about the ragel-users mailing list