g., treating characters as integers, which can be used to improve execution speed in some applications),
increase program size, and perhaps reduce ultimate efficiency. Tradeoffs make language design a challenging
occupation, and different tradeoffs make different languages more suitable for different types of tasks.
60 SOFTWARE [CHAP. 4
LANGUAGE SYNTAX AND SEMANTICS
To prepare a user-written program for execution, the language processor must perform several tasks. In order,
computer scientists refer to these tasks as scanning (lexical analysis), parsing (syntax analysis), and code generation
(semantic analysis).
Scanning, the first step, reads the character sequence that is a source code file and creates a sequence of
tokens of the language. Tokens are the words of a language, and tokens fall into several categories. A token
may be a key word like return or a reserved word like String, a special symbol like ???+??™, a variable name
or identifier like myCount, or a literal constant like the number 3.14 or the character string Please enter
your name:.
After the scanner ???tokenizes??? the source code, the parser accepts the list of tokens as input and builds
a ???parse tree??? according to the syntax rules of the language.
Pages:
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175