انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية العلوم للبنات
القسم قسم الحاسبات
المرحلة 3
أستاذ المادة اسراء هادي عبيد السلطاني
04/06/2018 08:53:03
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
Compiler: A compiler is a program that translates a high-level language program into a functionally equivalent low-level language program. Compilation:
The compiler takes as input a source program and produces as output an equivalent sequence of machine instructions.
Things to take into account in the compiler design
Correctness --- correct output of the execution --- report error correctly if the program is not following the language syntax
Efficiency ---How efficiency (fast) the compiler is generating the code (Compiler time) ---How efficiency the generated code (run time)
Debuggability
Intt a=5; Undefined the varivle intt with line number and the column number This process is very complex; hence, from the logical as well as an implementation point of view, it is customary to partition the compilation process into several phases. A phase is a logically cohesive operation that takes as input one representation of the source program and produces as output another representation .
The phases of a compiler
1-Lexical Analyzer (or Scanner): The lexical analysis phase reads the characters in the source program and groups them into streams of tokens; each token represents a logically cohesive sequence of characters, such as identifiers, operators, and keywords. These usual tokens are keywords such as DO or IF, identifier , such as X or NUM , operator symbols such as <= or + , and punctuation symbols such as parentheses . The character sequence that forms a token is called a "lexeme". Example: Const pi = 3.1416 The sub string pi is a lexeme for the token “identifier”
The output of the lexical analyzer is a stream of tokens which is passed to the next phase , the syntax analyzer or parser .The lexical analyzer is the interface between the source program and the compiler . What is called tokens depends on the language at the hand and , on some extent on the discretion of the compiler designer . There are two kinds of tokens: Specific such as IF or a semicolon and , and classes of strings such as identifiers constants labels. We shall treat a token as a pair consisting of two parts : a token type and a token value. A token consisting of specific string such as semicolon well be treated as having a type but no value . A token such as the identifier MAX has a type "identifier" and a value consisting of the string MAX. The lexical analyzer and the next phase , parser , are often grouped together into one pass. In that pass , the lexical analyzer operates either under the control of the parser or as a co routine with the parser . The parser asks the lexical analyzer for the next token , whenever the parser needs one. The lexical analyzer returns to the parser a code for the token that it found. In the case that the token is an identifier or another token with a value , the value is also passed to the parser .
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم
|