struct

Sthx::LongestOf

Inherits Sthx::RuleCollection < Sthx::Rule < Struct < Value < Object

The rule with most progress into the source string wins. This mode doesn't depend on initialization order, only on the content of the source string itself. So e.g. in "x" | "xx" and the source string "xx" the rule "xx" will match, and if the source string is "x" the rule "x" will match.

The slower option between FirstOf and LongestOf, as all branches must run for the winner to be determined.

Instance methods

advance(cursor : Cursor, data : TreeData, *, collect : Collect) : Advance::Result

Performs cursor motion and returns the result, one of Advance::Result: success Advance::Ok or failure Advance::Err.

data is the TreeData object built so far.

To implementors of this method: in case of failure to commit, cursor must be rolled back to its state before calling this method. In other words, advance is implemented in a "transaction" kind of way. Intermediate results and changes must never be available to the caller. This method either succeeds and mutates the cursor; or it fails and leaves the cursor intact.

Source