The given token indicates the end of a compound element. As such,
current stack element is popped off the stack and either reduced
into the element below, or returned. For example, when parsing an
S-expression (i.e. lisp), the token ) signifies the end of a
list.
The given token indicates the start of a new compound element. As
such, a new default element is pushed onto the stack. For
example, when parsing an S-expression (i.e. lisp), then upon
encountering a ( we start a new empty list.
Responsible for matching a certain pattern against a data stream
(e.g. a character stream). This can be used, for example, for
lexing an input stream into tokens.
Responsible for converting an input sequence (typically from a
string slice) into a token. A simple example which might form
part of an S-expression parser is:
A shift-reduce parser processes input one token at a time
(currently without backtracking). Tokens are transformed into
terms using two rules: shift and reduce. These operate over a
stack of (partially complete) terms.