Tinderbox v9 Icon

Expect operators

The expect family of operators looks at the current place in the text stream to ensure that the text is what you expect it to be.

Stream.expect("matchString")

Tests that the next characters in the stream are are a literal string "matchString", and advances the stream beyond "matchString". Otherwise, a failure occurs and parsing ceases.

Stream.expectWhitespace

Tests that the next characters in the stream are whitespace, such as spaces, tabs, and carriage returns (i.e 'whitespace' as in regular expression terms). It advances the stream to the first non-whitespace character. A failure occurs if the next character is not whitespace.

Stream.expectNumber

Tests that the next characters in the stream can be interpreted as a number. Numbers include "0", "5.7", and "-13". Skips over the number. A failure occurs if the next character is not part of a number.

Stream.expectWord

Tests that the next character is not whitespace, punctuation, or a digit. Skips to the next whitespace, punctuation, or digit. Otherwise, a failure occurs and parsing ceases.