will be aided by a set of command line tools written
for this purpose. Before we proceed, let us formally
introduce the concepts.
The structured pushdown automaton (SPA) (José
Neto and Magalhães, 1981; José Neto, 1993) is a kind
of pushdown automaton composed of a set of mutu-
ally recursive finite automata, also known as subma-
chines. Unlike the traditional pushdown automaton,
the stack is only used to store references to return
states on each submachine call. Calls and returns con-
sist on transferring control from one submachine to
another; this special transition uses the input symbol
to make a decision on which transition should be ex-
ecuted (the symbol is then consumed in the next tran-
sition) (José Neto, 1993; José Neto, 1994).
A structured pushdown automaton M is defined as
M = (Q,A,Σ,Γ,P,Z
0
,q
0
,F), in which Q is the set of
states, A is the set of submachines, defined as fol-
lows, Σ is the automaton alphabet, corresponding to
the non-empty set of input symbols, Γ is the set of
stack symbols, P is the transition relation, q
0
∈ Q
is the initial state (of the first submachine), Z
0
is a
special symbol acting as an empty stack marker, and
F ⊆ Q is the set of accepting states (of the first sub-
machine) (José Neto and Magalhães, 1981; José Neto,
1993).
A submachine a
i
∈ A is defined as a traditional fi-
nite automaton a
i
= (Q
i
,Σ
i
,P
i
,q
i,0
,F
i
), in which Q
i
⊆
Q is the set of states of a
i
, Σ
i
⊆ Σ is the set of input
symbols of a
i
, q
i,0
is the entry state of a
i
, P
i
⊆ P is the
transition relation of a
i
, and F
i
⊆ F is the set of return
states of a
i
.
The transition relation P is defined as P ⊆ Γ ×
Q × Σ × Γ × Q, in the form (γg,e,sα) → (γg
′
,e
′
,α),
in which e,e
′
are the current and target states, respec-
tively, s is the consumed symbol, α is the remainder of
the input string, g is the current top of the stack, g
′
is
the new top of the stack, and γ is the remainder of the
stack. A configuration is an element of Q × Σ
∗
× Γ
∗
,
and a relation between successive configurations ⊢ is
defined as follows:
– Symbol consumption: (q,σw,uv) ⊢ (p,w,xv), with
p,q ∈ Q, u,x ∈ Γ, v ∈ Γ
∗
, σ ∈ Σ∪{ε}, w ∈ Σ
∗
, if σ
was consumed, x = u, e (γ, q, σα) → (γ, p,α) ∈ P.
– Submachine call: (q,w,uv) ⊢ (r,w, xv), with q,r ∈
Q, u ∈ Γ, v, x ∈ Γ
∗
, w ∈ Σ
∗
, x = pu, with a call to
the submachine R, initial state r, return in p, and
(γ,q,α) → (γp, r,α) ∈ P.
– Submachine return: (q,w, uv) ⊢ (p, w,v), with
p,q ∈ Q, u,x ∈ Γ, v ∈ Γ
∗
, w ∈ Σ
∗
, u = p, with sub-
machine return to p, and (γg,q,α) → (γ,g,α) ∈ P.
The language recognized by a structured push-
down automaton M is given by L(M) = {w ∈ Σ
∗
|
(q
0
,w, Z
0
) ⊢
∗
( f,ε,Z
0
), f ∈ F}.
A submachine call can be graphically represented
by a transition with double lines as illustrated in Fig-
ure 1. Note that, from state q
im
of submachine a
i
,
execution is transferred to the submachine a
j
and the
address regarding the return state q
in
is inserted into
the top of the stack. In the example, the current state
becomes q
i0
, which is the initial of the submachine
a
j
.
q
im
q
in
q
j0
a
j
...
a
j
Figure 1: Example of call to the submachine a
j
.
It is important to note that, as a matter of
model organization, it is assumed that a
i
,a
j
∈ A,
a
i
= (Q
i
,Σ
i
,P
i
,q
i,0
,F
i
), a
j
= (Q
j
,Σ
j
,P
j
,q
j,0
,F
j
), Q
i
∩
Q
j
=
/
0 and P
i
∩P
j
=
/
0, i.e. sets of states and mappings
of submachines are disjoint.
Automata are devices that, based on a set of for-
mation rules of a language, can decide whether an in-
put string is a valid sentence, i.e. the input string is a
element of the set of all sentences in that language. In
the late 1970s, Wirth (Wirth, 1977) presented a met-
alanguage for describing programming languages, in
an attempt to provide a simplified notation as alterna-
tive to existing initiatives, specially the Backus-Naur
Form (BNF); such metalanguage became known as
Wirth syntax notation (WSN) and has the following
properties:
i) The notation shows a clear distinction between
metasymbols, terminal and nonterminal symbols.
Existing metasymbols are =, ., (, ), [, ], {, },
| and ". A nonterminal symbol is denoted by an
identifier, i.e. one letter followed by zero or more
letters and digits (as an usual variable definition
in a programming language), while the terminal
symbol is expressed by a string enclosed in dou-
ble quotes.
ii) There is no restriction regarding the use of meta-
symbols as symbols of language being described.
For example, the metasymbol | differs from ter-
minal symbol "|".
iii) The notation avoids heavy use of recursion to ex-
press simple repetitions by having a construct to
express explicit iteration. Repetition is denoted
by curly brackets.
iv) There is no need to use an explicit symbol to
represent the empty string, such as hemptyi in
BNF or ε, because the notation already has con-
structs that address this situation. Optionality is
expressed by square brackets.