Java Reference
In-Depth Information
E
Prefix
(
E
)
v
Tail
f
+
E
v
Tail
Figure 4.2: The parse tree for f ( v + v) .
and its parse tree, a phrase of the sentential form is a sequence of symbols
descended from a single nonterminal in the parse tree. A simple or prime
phrase is a phrase that contains no smaller phrase. That is, it is a sequence of
symbols directly derived from a nonterminal. The handle of a sentential form
is the leftmost simple phrase. (Simple phrases cannot overlap, so “leftmost”
is unambiguous.) Given the parse tree of Figure 4.2 and the sentential form
f(vTail), f and vTailare simple phrases and f is the handle. Handles are
important because they represent individual derivation steps, which can be
recognized by various parsing techniques.
4.1.4 Other Types of Grammars
Although CFGs serve well to characterize syntax, most programming lan-
guages contain rules that are not expressible using CFGs. For example, the
rule that variables must be declared before they are used cannot be expressed
because a CFG provides no mechanism for transmitting to the body of a pro-
gram the exact set of variables that has been declared. In practice, syntactic
details that cannot be represented in a CFG are considered part of the static
semantics and are checked by semantic routines (along with scope and type
rules).
 
 
Search WWH ::




Custom Search