[ragel-users] Problematic machine specification
Adrian Thurston
thurs... at cs.queensu.ca
Mon Jan 1 21:57:14 UTC 2007
Hi Matt,
I noticed a couple spots to fix. Since the line machine is given with
the + operator it requires at least one character. Use * instead and
empty lines (following +/- etc) will be accepted.
The 'print' builtin machine does not accept tabs, so any diff with tabs
will fail.
When the machine hits an error it transitions into the error state and
then breaks out of the loop from there. Look at p[-1] after the loop to
see on what character the error occurred. Alternatively you can embed an
error action and look at p[0] from within the action.
If you want to see the state that the error occurred in you'll need to
embed an error action and look at fcurs (this is macro rewritten by ragel).
Cheers (and happy new year)
Adrian
Matt Mower wrote:
> Hi folks.
>
> I'm writing an app that needs to parse the output from svn diff
> although not to any great degree of detail. For various reasons (blame
> Zed!) I decided to use this as an opportunity to learn Ragel.
>
> With a lot of help from Zed I have something that seems close but
> isn't quite working. The problem section revolves around the contents
> of a diff hunk. This looks something like:
>
> @@ -205,3 +205,15 @@
> .hugeTag {
> font-size: 125%;
> }
> +
> +.asp_timestamp_col {
> ...
>
> the first three lines after the line beginning @@... have a space
> prefix (meaning a line common to both files), the next line has a '+'
> prefix (meaning a new line). A hunk ends when you reach a line that
> doesn't begin with " ", "+", or "-".
>
> The problem is that the machine recognizes the first three lines of my
> example (prefixed " ") but comes back with an error when it reaches
> the first line prefixed "+". Looking at the diagram (diffBody.png
> attached) for the diffBody machine it looks to me as if it should
> correctly parse the example.
>
> If anyone can help point out where I am going wrong that would be much
> appreciated. I'm not sure if & how I can get it to log the state or
> character being processed when the error was raised. That too would be
> useful.
>
> My application is being written in Objective-C. So far as I can tell
> that doesn't significantly muddy the waters and the O-C bits seem to
> be working.
>
> Many thanks,
>
> Matt
>
>
> ------------------------------------------------------------------------
>
More information about the ragel-users
mailing list