ragel icon indicating copy to clipboard operation
ragel copied to clipboard

Is the exit transition being dropped correctly?

Open ioquatix opened this issue 5 years ago • 0 comments

I am trying to resolve a simple non-determinism.

%%{
  machine query;

  # An application/x-www-form-urlencoded parser based on the
definition by WhatWG.
  # Based on https://url.spec.whatwg.org/#application/x-www-form-urlencoded
  pchar = any - [&=\[\]];

  # All transitions default to priority 0. We set the integer exit
priority to 1, which ensures a transition to the next state will only
invoke %integer_end (the lower priority %string_end transition is
discarded).
  integer = ([0-9]+) %(index, 1) >integer_begin %integer_end;
  string = (pchar+) $(index, 0) >string_begin %string_end;

  value = (pchar*) >value_begin %value_end;

  index = string (
    '[' (integer | string) ']'
  )* ('[]' %append)?;

  pair = (
    index ('=' value)?
  ) %pair;

  main := ((pair '&')* pair)?;
}%%

When parsing the following input: q[0]=0

I see that on the transition for ] it will invoke both %integer_end as well as %string_end. But I was under the impression the lower priority transition would be dropped.

Thanks for any advice you can give me.

ioquatix avatar Feb 17 '20 09:02 ioquatix