Tuesday, March 26, 2013

Chapter 3 - Describing Syntax and Semantics

Name : Agata Sri Sartika Servina
NIM : 1601218804
Class: 02PCT
Special thanks to : Mr. Tri Djoko Wahjono, Ir., M.Sc.
Review Question
1. The syntax of a programming language is the form of its expressions, statements, and program units. Semantics is the meaning of those expressions, statements, and program units.
2. A language generator is a device that can be used to generate the sentences of a language. We can think of the generator as having a button that produces a sentence of the language every time it is pushed . In this term, people prefer certain forms of generators over recognizers because they can more easily read and understand them. By contrast, the syntax- checking portion of a compiler is not as useful a language description for a programmer because it can be used only in trial and error mode.
4. Sentence form is a program consists of the special word begin, followed by a list of statements separated by semicolons, followed by the special word end. Sentential form is each of the strings in the derivation, including
6. Synthesized attributes are used to pass semantic information up a parse tree, inherited attributes are used to pass semantic information down and across a tree.
9. The wp function is helpful to treat the process of producing a weakest precondition as a function. It is called a predicate transformer because it takes a predicate, or assertion, as a parameter and returns another predicate.
10. Total correctness is the axiomatic description of the loop when the loop termination is shown Partial correctness is the other condition can be met but termination is not guaranteed.
23. Axiomatic semantics, named because it is based on mathematical logic.
28.A weakest precondition is the least restrictive precondition that will guarantee the postcondition. It is often called a predicate transformer because it takes a predicate, or assertion as a parameter and returns another predicate.
Problem Set
1. Syntax Error: error due to missing colon, semicolon, parenthesis, etc. Syntax is the way in which we construct sentences by following principles and rules.
Examples:
1. int x = “three”;
In C++, this will not compile because it does not follow the syntax of the language and does not make any sense to the compiler.
5. →id = = id | id != id
7. S A {bA}
Aa [b]A
b |
a | ab
8. A fully attributed parse tree is a condition when all the attributed values in parse tree have been computed.
16. =
→ A | B | C
(+ | -)
| ()
|
17. S → A | A B
B → b A | b A B
A → a A | a b A
18. if all the attributed values in a parse tree have been computed. a parse tree of an attributed grammar is the parse tree based on its underlying BNF grammar, with a possibly empty set of attribute values attached to each node.
24. a. a= 2*b+1
b=a-3 {b<0}
b. a= 3*(2*b+a)
b= 2*a-1 {b>5}
2*a-1>5
2*a>6
(a). -> a-3<0
a<3
a=2*b+1 {a<3}
2*b+1<3
2*b<2
b<1
(b). -> a= 3*(2*b+a) {a>3}
3*(2*b+a)>3
6*b+3*a>3
2*b+a>1
b>(1-a)/2

Monday, March 18, 2013

Chapter 2 - Evolution of the Major Programming Languages

Name : Agata Sri Sartika Servina
NIM : 1601218804
Class: 02PCT
Special thanks to : Mr. Tri Djoko Wahjono, Ir., M.Sc.
Review Question
1. Designed in 1943 and Published in 1972
3. Program Calculus
7. John Backus
8. John Mauchly. Because, it clearly simplified the programming process, but at the expense of execution time.
9. IBM,Fortran 0.
10. Independent compilation of subroutines
11. Logical loop control statements
12. Fortran IV
13. Fortran 77
14. Because, Linguists were concerned with natural language processing
15. Records, arrays, complex numbers and character strings
17. Scheme
18. GAMM and ACM
19. C has adequate control statements and data-sructuring facilities to allow its use in many application areas. It also has a rich set of operators that provide a high degree of expressiveness.
21. COBOL.
22. Common Business Language (CBL).
23. 1959
28. Designed to replace FORTRAN & COBOL languages.
33. ALGOL-W
46. Objective-C 2.0.
47. Ken Thompson.
49. Sun Microsystems.
54. You will find it used in a web browser.
64. .NET
Problem Set
1. The logical loop control statements, and an “if” with an optional “else” caluse.
2. Short Code clearly simplified the programming process, but at the expense of execution time. Short Code interpretation was approximately 50 times slower than machine code (hand calculator).
6. The most common syntax error in C i think is forget to end a statement with semicolon (;)
8. Because, Speedcoding fills up a lot of space on the disk so it’s ineffective
9. The choice of the letters for this convention was based on the fact that at that time scientists and engineers used letters as variables subscripts, usually i, j, and k, and then Fortran’s designers threw in the three additional letters.
13. Because, C is flexible and well suited for various applications and also a compiler for C was part of the widely used UNIX operating system in 1980s.
15. Yes, Fortran, C++, COBOL, ALGOL.
16. depend to the programmer they want to use a simple or a complex, but many will choose simple because it is more readable and more easy to spot a mistake.
25. Java servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers, so they can be thought of as Java Apllets that run on servers instead of in web browsers

Monday, March 4, 2013

Chapter 1 - Preliminaries

Name : Agata Sri Sartika Servina
NIM : 1601218804
Class: 02PCT
Special thanks to : Mr. Tri Djoko Wahjono, Ir., M.Sc. ()
Review Question
3.The first language of scientific applications was FORTRAN
4.COBOL
13.A program is said to be reliable if it performs to its specifications under all conditions.
15.Aliasing is a distortion caused in analog-to-digital conversion by a too low rate of data sampling. Aliasing can occur either because the anti-alias filter in the A-D converter (or in a sample-rate converter) isn’t very good, or because the system has been overloaded.
16.Exception handling is a mechanism in which a programming construct is used to consistently trap, intercept and handle the error occurred during application execution. The Common Language Runtime (CLR) of .NET Framework is designed to use an exception handling model based on exception objects and protected blocks of code.
23.Smalltalk
26.a compiler.
Problem Set
2.Refer from Wikipedia.com the first programmer was Ada Lovelace. She is today appreciated as the “first programmer” since she was writing programs that is, encoding an algorithm in a form to be processed by a machine for a machine that Babbage had not yet built.
8.> pros:
a. easier way to maintain error
b. make the collaborative working on project easier
c. save development time
d. easier testing
> Cons:
a. function and subroutines require knowledge of programming language so it is a difficult thing for a programmer how doesn’t have enough skill
b. different programming language usually has a different way to create a function and subroutines so in this case it makes the programmer have to learn many different way to make function and subroutines in different programming language.
13.One of the first programming language i learned is C. C uses a compiler