Rabu, 15 Oktober 2014

ASSIGNMENT III

Lecture:Tri Djoko Wahjono,Ir.,M.Sc.(D0206)

Class:LM01

ASSIGNMENT III


REVIEW QUESTION CHAPTER III

11.Q: How is the order of evaluation of attributes determined for the trees of a
given attribute grammar?

A:Semantik statis bahasa hanya secara tidak langsung terkait dengan makna program selama eksekusi; melainkan harus dilakukan dengan bentuk hukum dari program
(sintaks bukan semantik). Banyak aturan semantik statis bahasa menyatakan kendala jenisnya. Semantik statis dinamakan demikian karena analisis yang dibutuhkan untuk
memeriksa spesifikasi ini dapat dilakukan pada waktu kompilasi.
      Semantik dinamis adalah makna ekspresi, pernyataan, dan unit program bahasa pemrograman.

12. Q:What is the primary use of attribute grammars?

A:Atribut tata bahasa utama yang digunakan untuk memberikan deskripsi lengkap sintaks dan semantik statis bahasa pemrograman.

13.Q: Explain the primary uses of a methodology and notation for describing
the semantics of programming languages.

A:Jika pemutusan lingkaran dapat ditampilkan, deskripsi aksiomatik loop disebut total kebenaran. Jika kondisi lain dapat dipenuhi tetapi terminasi tidak
dijamin, hal itu disebut correctnes parsial.

14.Q: Why can machine languages not be used to define statements in operational
semantics?

A:Bahasa mesin tidak dapat digunakan untuk mendefinisikan pernyataan dalam semantik operasional karena beberapa masalah. Pertama, langkah-langkah individu dalam pelaksanaan mesin
bahasa dan perubahan yang dihasilkan pada keadaan mesin terlalu kecil dan terlalu banyak. Kedua, penyimpanan komputer yang nyata terlalu besar dan kompleks.

15. Q:Describe the two levels of uses of operational semantics.

A:Pada tingkat tertinggi, yang menarik adalah di hasil akhir dari pelaksanaan program yang lengkap. Hal ini kadang-kadang disebut semantik operasional alami.
Pada tingkat terendah, semantik operasional dapat digunakan untuk menentukan makna yang tepat dari sebuah program melalui pemeriksaan urutan lengkap negara
perubahan yang terjadi ketika program dijalankan. Penggunaan ini kadang-kadang disebut semantik operasional struktural.

PROBLEM SET CHAPTER III

11. Consider the following grammar:
<S> → <A> a <B> b
<A> → <A> b | b
<B> → a <B> | a

Which of the following sentences are in the language generated by this
grammar?
a. baab
b. bbbab
c. bbaaaaa
d. bbaab

=<S> → <A> <B> <C>
<A> → a <A> | a
<B> → b <B> | b
<C> → c <C> | c

12. Consider the following grammar:
<S> → a <S> c <B> | <A> | b
<A> → c <A> | c
<B> → d | <A>

Which of the following sentences are in the language generated by this
grammar?
a. abcd
b. acccbd
c. acccbcc
d. acd
e. accc

LHS non-terminal S didefinisikan sebagai non-terminal A, terminal, non-terminal B dan terminal b, di mana non-terminal A dapat nol atau lebih b atau satu b, dan di mana non-terminal B dapat menjadi salah satu atau lebih adalah satu atau a;

Menghasilkan satu atau lebih b atau satu b, satu, satu atau lebih atau satu, dan satu b.
Jawaban a (Baab) dan d (bbaab) mematuhi produksi ini.

13. Write a grammar for the language consisting of strings that have n
copies of the letter a followed by the same number of copies of the
letter b, where n > 0. For example, the strings ab, aaaabbbb, and

=<S> -> <A>
<A> -> a <A> b <B>
aaaaaaaabbbbbbbb are in the language but a, abb, ba, and aaabb are not.

14. Draw parse trees for the sentences aabb and aaaabbbb, as derived from
the grammar of Problem 13.

=<stmt> -> <A>
<A> -> A <A> b | ab
pohon untuk aabb
pohon untuk aaaabbbb

15. Convert the BNF of Example 3.1 to EBNF

=<program> -> begin <stmt_list> end

<stmt_list> -> <stmt>

| <stmt> ; <stmt_list>

<stmt> -> <var> = <expression>

<var> -> A | B | C

<expression> -> <var> {(+|-) <var>}

ASSIGNMENT II

Lecture:Tri Djoko Wahjono,Ir.,M.Sc.(D0206)

Class:LM01

REVIEW QUESTION CHAPTER II

11.Q: What control flow statements were added to Fortran IV to get Fortran 77?

A:logical loop statements and IF with an optional ELSE

12.Q: Which version of Fortran was the first to have any sort of dynamic variables?

A:fortran 90

13.Q: Which version of Fortran was the first to have character string handling?

A:fortran 77

14.Q:Why were linguists interested in artificial intelligence in the late 1950s?

A: Linguists were concerned with natural language processing.

15.Q: Where was LISP developed ? By whom?

A:it was developed at MIT by john McCarthy


PROBLEM SET CHAPTER II


11.Q: Was IBM’s assumption, on which it based its decision to develop PL/I, correct, given the history of computers and language developments since 1964?

A:The assumption is correct,because on 70s, PL/I used worldwide for bussiness and science application althought have many failure past years and after years.

12.Q: Describe, in your own words, the concept of orthogonality in programming language design.

A: concept of orthogonality in programming languange to create a new program that teaches the language to be independent of other capabilities and can be combined with a variety of programming language features so that each combination has a meaning and can be used as widely as possible.

13.Q:What is the primary reason why PL/I became more widely used than ALGOL 68?

A:PL/I achieved far greater acceptance than ALGOL 68, due largely to IBM’s promotional efforts and the problems of understanding and implementing ALGO 68.Implementation was a difficult problem for both, but PL/I had the resources of IBM to apply to building a compiler. ALGOL 68 enjoyed no such benefactor.

14.Q:What are the arguments both for and against the idea of a typeless language?

A:In a typeless language, a variable can contain any kind of value (numeric, string, boolean), so it’s more flexible. In the other side it is more prone to make mistakes for the programmer and may resulted ambiguity.

15.Q: Are there any logic programming languages other than Prolog?

A:FORTRAN, LISP and ALGO 60