<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>1.1 Notation</TITLE>
<META NAME="description" CONTENT="1.1 Notation">
<META NAME="keywords" CONTENT="ref">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="ref.css">
<LINK REL="previous" HREF="introduction.html">
<LINK REL="up" HREF="introduction.html">
<LINK REL="next" HREF="lexical.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="lexical.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="introduction.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="introduction.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Reference Manual</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><img width=32 height=32 align=bottom border=0 alt=""
 src="../icons/blank.gif"></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="lexical.html">2. Lexical analysis</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="introduction.html">1. Introduction</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="introduction.html">1. Introduction</A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION003100000000000000000"></A>
<BR>
1.1 Notation
</H1>

<P>
The descriptions of lexical analysis and syntax use a modified BNF
grammar notation.  This uses the following style of definition:
<a name="l2h-1"></a>
<a name="l2h-2"></a>
<a name="l2h-3"></a>
<a name="l2h-4"></a>

<P>
<dl><dd><pre class=verbatim>
name:           lc_letter (lc_letter | "_")*
lc_letter:      "a"..."z"
</pre></dl>

<P>
The first line says that a <tt>name</tt> is an <tt>lc_letter</tt> followed by
a sequence of zero or more <tt>lc_letter</tt>s and underscores.  An
<tt>lc_letter</tt> in turn is any of the single characters "<tt class=character>a</tt>"
through "<tt class=character>z</tt>".  (This rule is actually adhered to for the
names defined in lexical and grammar rules in this document.)

<P>
Each rule begins with a name (which is the name defined by the rule)
and a colon.  A vertical bar (<tt>|</tt>) is used to separate
alternatives; it is the least binding operator in this notation.  A
star (<tt>*</tt>) means zero or more repetitions of the preceding item;
likewise, a plus (<tt>+</tt>) means one or more repetitions, and a
phrase enclosed in square brackets (<tt>[ ]</tt>) means zero or one
occurrences (in other words, the enclosed phrase is optional).  The
<tt>*</tt> and <tt>+</tt> operators bind as tightly as possible;
parentheses are used for grouping.  Literal strings are enclosed in
quotes.  White space is only meaningful to separate tokens.
Rules are normally contained on a single line; rules with many
alternatives may be formatted alternatively with each line after the
first beginning with a vertical bar.

<P>
In lexical definitions (as the example above), two more conventions
are used: Two literal characters separated by three dots mean a choice
of any single character in the given (inclusive) range of ASCII
characters.  A phrase between angular brackets (<tt>&lt;...&gt;</tt>) gives an
informal description of the symbol defined; e.g., this could be used
to describe the notion of `control character' if needed.
<a name="l2h-5"></a>
<a name="l2h-6"></a>

<P>
Even though the notation used is almost the same, there is a big
difference between the meaning of lexical and syntactic definitions:
a lexical definition operates on the individual characters of the
input source, while a syntax definition operates on the stream of
tokens generated by the lexical analysis.  All uses of BNF in the next
chapter (``Lexical Analysis'') are lexical definitions; uses in
subsequent chapters are syntactic definitions.
<p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="lexical.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="introduction.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="introduction.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Reference Manual</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><img width=32 height=32 align=bottom border=0 alt=""
 src="../icons/blank.gif"></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="lexical.html">2. Lexical analysis</A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="introduction.html">1. Introduction</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="introduction.html">1. Introduction</A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
