Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / ref / notation.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="ref.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="ref.html" title='Python Reference Manual' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="implementations.html" />
13<link rel="parent" href="introduction.html" />
14<link rel="next" href="lexical.html" />
15<meta name='aesop' content='information' />
16<title>1.2 Notation</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="1.1 Alternate Implementations"
24 href="implementations.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="1. Introduction"
27 href="introduction.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="2. Lexical analysis"
30 href="lexical.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Reference Manual</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><img src='../icons/blank.png'
37 border='0' height='32' alt='' width='32' /></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="implementations.html">1.1 Alternate Implementations</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="introduction.html">1. Introduction</A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="lexical.html">2. Lexical analysis</A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H1><A NAME="SECTION003200000000000000000"></A><A NAME="notation"></A><a id='l2h-1' xml:id='l2h-1'></a>
55<BR>
561.2 Notation
57</H1>
58
59<P>
60The descriptions of lexical analysis and syntax use a modified BNF
61grammar notation. This uses the following style of definition:
62
63<P>
64<dl><dd class="grammar">
65<div class="productions">
66<table>
67<tr>
68 <td><a id='tok-name' xml:id='tok-name'>name</a></td>
69 <td>::=</td>
70 <td><a class='grammartoken' href="notation.html#tok-lc_letter">lc_letter</a> (<a class='grammartoken' href="notation.html#tok-lc_letter">lc_letter</a> | "_")*</td></tr>
71 <tr>
72 <td><a id='tok-lc_letter' xml:id='tok-lc_letter'>lc_letter</a></td>
73 <td>::=</td>
74 <td>"a"..."z"</td></tr>
75</table>
76</div>
77<a class="grammar-footer"
78 href="grammar.txt" type="text/plain"
79 >Download entire grammar as text.</a>
80</dd></dl>
81
82<P>
83The first line says that a <code>name</code> is an <code>lc_letter</code> followed by
84a sequence of zero or more <code>lc_letter</code>s and underscores. An
85<code>lc_letter</code> in turn is any of the single characters "<tt class="character">a</tt>"
86through "<tt class="character">z</tt>". (This rule is actually adhered to for the
87names defined in lexical and grammar rules in this document.)
88
89<P>
90Each rule begins with a name (which is the name defined by the rule)
91and <code>::=</code>. A vertical bar (<code>|</code>) is used to separate
92alternatives; it is the least binding operator in this notation. A
93star (<code>*</code>) means zero or more repetitions of the preceding item;
94likewise, a plus (<code>+</code>) means one or more repetitions, and a
95phrase enclosed in square brackets (<code>[ ]</code>) means zero or one
96occurrences (in other words, the enclosed phrase is optional). The
97<code>*</code> and <code>+</code> operators bind as tightly as possible;
98parentheses are used for grouping. Literal strings are enclosed in
99quotes. White space is only meaningful to separate tokens.
100Rules are normally contained on a single line; rules with many
101alternatives may be formatted alternatively with each line after the
102first beginning with a vertical bar.
103
104<P>
105In lexical definitions (as the example above), two more conventions
106are used: Two literal characters separated by three dots mean a choice
107of any single character in the given (inclusive) range of ASCII
108characters. A phrase between angular brackets (<code>&lt;...&gt;</code>) gives an
109informal description of the symbol defined; e.g., this could be used
110to describe the notion of `control character' if needed.
111
112<P>
113Even though the notation used is almost the same, there is a big
114difference between the meaning of lexical and syntactic definitions:
115a lexical definition operates on the individual characters of the
116input source, while a syntax definition operates on the stream of
117tokens generated by the lexical analysis. All uses of BNF in the next
118chapter (``Lexical Analysis'') are lexical definitions; uses in
119subsequent chapters are syntactic definitions.
120
121<DIV CLASS="navigation">
122<div class='online-navigation'>
123<p></p><hr />
124<table align="center" width="100%" cellpadding="0" cellspacing="2">
125<tr>
126<td class='online-navigation'><a rel="prev" title="1.1 Alternate Implementations"
127 href="implementations.html"><img src='../icons/previous.png'
128 border='0' height='32' alt='Previous Page' width='32' /></A></td>
129<td class='online-navigation'><a rel="parent" title="1. Introduction"
130 href="introduction.html"><img src='../icons/up.png'
131 border='0' height='32' alt='Up One Level' width='32' /></A></td>
132<td class='online-navigation'><a rel="next" title="2. Lexical analysis"
133 href="lexical.html"><img src='../icons/next.png'
134 border='0' height='32' alt='Next Page' width='32' /></A></td>
135<td align="center" width="100%">Python Reference Manual</td>
136<td class='online-navigation'><a rel="contents" title="Table of Contents"
137 href="contents.html"><img src='../icons/contents.png'
138 border='0' height='32' alt='Contents' width='32' /></A></td>
139<td class='online-navigation'><img src='../icons/blank.png'
140 border='0' height='32' alt='' width='32' /></td>
141<td class='online-navigation'><a rel="index" title="Index"
142 href="genindex.html"><img src='../icons/index.png'
143 border='0' height='32' alt='Index' width='32' /></A></td>
144</tr></table>
145<div class='online-navigation'>
146<b class="navlabel">Previous:</b>
147<a class="sectref" rel="prev" href="implementations.html">1.1 Alternate Implementations</A>
148<b class="navlabel">Up:</b>
149<a class="sectref" rel="parent" href="introduction.html">1. Introduction</A>
150<b class="navlabel">Next:</b>
151<a class="sectref" rel="next" href="lexical.html">2. Lexical analysis</A>
152</div>
153</div>
154<hr />
155<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
156</DIV>
157<!--End of Navigation Panel-->
158<ADDRESS>
159See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
160</ADDRESS>
161</BODY>
162</HTML>