Hi,<div><br></div><div>I'm trying to write a simple html lexer with ragel.</div><div>I have something looking like this, to match and take an action on the attribute 'src=' potentially found in several tag attributes :</div>
<div><br></div><div><div> tag_content = (</div><div> ('src='i ((('\'' string_sgl_exp) | '"' string_dbl_exp)</div><div> >src_attr_start</div><div> @src_attr_end))</div>
<div><br></div><div> | any</div><div> )** <>lerr{ };</div><div><br></div><div> tag_exp = tag_content :>> '>';</div></div><div><br></div><div>My problem is if I create an attribute <img srt="..."> (srt is not a proper attribute, but it does generate a parse error).</div>
<div>What I'd like to do would be <>lerr{ fhold; fgoto tag_content; }, which would work if tag_content was an entry point.</div><div>But I use tag_exp in several places where an entry point wouldn't work, for instance :</div>
<div><br></div><div>img_tag := tag_exp [...] @end_img_action;</div><div>script_tag := tag_exp [...] @end_script_tag_action;</div><div><br></div><div>I've considered creating a ragel scanner, but I don't really care for backtracking, I'd just like to be able to hide the error. This would work exactly the way I want to, by doing a fgoto tag_content. It would basically restart the parse on t='...' and have it would fall under the "any" category.</div>
<div><br></div><div>Is there an elegant way to do this, or to just hide the error ?</div><div><br></div><div>Thank you,</div><div><br></div><div>Matthieu.</div>