基本的に入力ストリームの特定のパターンに一致するため、PetitParserを使用できます。わかりやすくするためにいくつかのコメントを追加したパーサー定義は次のとおりです。
" the parser that accepts the symbol #signal1 "
signal := PPPredicateObjectParser expect: #signal1.
" the parser that accepts the symbol #signal1 not followed by something else "
pattern := signal , signal negate.
" the parser that extract the second symbol "
parser := pattern map: [ :signal :random | random ].
入力データに対してそれを実行すると、次のようになります。
data := #(noise1 noise2 noise3 signal1 signal1
signal1 signal1 randomButInteresting
noise4 noise5).
parser matchesIn: data -> #(randomButInteresting)