Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / The second phase of the compiler is syntax analysis or parsing

The second phase of the compiler is syntax analysis or parsing

Computer Science

The second phase of the compiler is syntax analysis or parsing. The parser uses
the  rst components of the tokens produced by the lexical analyzer to create
a tree-like intermediate representation that depicts the grammatical structure
of the token stream. A typical representation is a syntax tree in which each
interior node represents an operation and the children of the node represent the
arguments of the operation. A syntax tree for the token stream (1.2) is shown
as the output of the syntactic analyzer in Fig. 1.7.
This tree shows the order in which the operations in the assignment
position = initial + rate * 60
are to be performed. The tree has an interior node labeled with hid; 3i as
its left child and the integer 60 as its right child. The node hid; 3i represents
the identier rate. The node labeled makes it explicit that we must  rst multiply the value of rate by 60. The node labeled + indicates that we must
add the result of this multiplication to the value of initial. The root of the
tree, labeled =, indicates that we must store the result of this addition into the
location for the identier position. This ordering of operations is consistent
with the usual conventions of arithmetic which tell us that multiplication has
higher precedence than addition, and hence that the multiplication is to be
performed before the addition.
The subsequent phases of the compiler use the grammatical structure to help
analyze the source program and generate the target program. In Chapter 4 we shall use context-free grammars to specify the grammatical structure of
programming languages and discuss algorithms for constructing ecient syntax
analyzers automatically from certain classes of grammars. In Chapters 2 and 5 we shall see that syntax-directed denitions can help specify the translation of
programming language constructs.
1.2.3 Semantic Analysis
The semantic analyzer uses the syntax tree and the information in the symbol
table to check the source program for semantic consistency with the language
denition. It also gathers type information and saves it in either the syntax tree
or the symbol table, for subsequent use during intermediate-code generation.
An important part of semantic analysis is type checking, where the compiler
checks that each operator has matching operands. For example, many program-
ming language denitions require an array index to be an integer; the compiler must report an error if a  oating-point number is used to index an array. The language specication may permit some type conversions called coer-
cions. For example, a binary arithmetic operator may be applied to either a
pair of integers or to a pair of  oating-point numbers. If the operator is applied
to a  oating-point number and an integer, the compiler may convert or coerce
the integer into a  oating-point number.

Intricate Computer Solutions provides services to corporate and individual customers. During the month of June, the corporate business segment provided services to 500 customers and earned $80,000 in revenue. The individual business segment provided services to 300 customers and earned $40,000 in revenue. The variable costs for the corporate and individual business segments amounted to $32,500 and $25,000, respectively. In addition, the ?xed costs of the company amounted to $7,500. Calculate the contribution margin from each corporate customer. (Round your answer to the nearest cent.) 0 A. $50.00 0 B. $95.00 0 C. $25.00 0 D. $80.00

14.5 COMPUTER SOLUTION OF A TRILATERATED QUADRILATERAL The quadrilateral shown in Figure 14.4 was adjusted using the software MATRIX. In this problem. points Bucky and Badger are control stations whose coordinates are held fixed. The five distances observed are: Line Distance (ft) Badger-Wisconsin 5870.302 Badger-Campus 7297.588 Wisconsin-Campus 3616.434 Wisconsin-Bucky 5742.878 Campus-Bucky 5123.760 Legend: A Control station New station Wisconsin Badger Bucky Campus Figure 14.4 Quadrilateral network. The state plane control coordinates in units of feet for station Badger are x = 2.410.000.000 and y = 390.000.000, and for Bucky are x = 2,411.820.000 and y = 386,881.222.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE