NIM : 1801428434
Here is the third assignment of Programming Language Concepts course. The question is taken from "Concepts of Programming Language, 10th edition" from Robert W. Sebesta in chapter 3:
Review Questions
1. Define syntax and semantics.
= Syntax and semantics are related to each
other, and both terms are used in relation to aspects of language. Syntax is
the form of its language expressions, statements, and program units. Semantics
is the meaning of those expressions and statements.
2.
Who are language descriptions for?
= Language description is like an instruction
to use the language itself. Hence, the language description is made for the implementers,
user, and also software developer to determine the semantics of a programming
language.
3.
Describe the operation of a general language
generator.
= A general language generator is a device
that can be used to generate the sentences of a language. However, it generates
sentence that is unpredictable, therefore a language generator is a limited usefulness
as a language descriptor
4.
Describe the operation of a general language
recognizer.
= A language recognizer is used to indicate
whether the input of a given string is in a specific language or not. A
language recognizer is capable of reading characters or string in the language.
Such devices are like filters to determine whether the syntax is from a
specific language.
5.
What is the difference between a sentence and a
sentential form?
= A sentence of a language is generated
through sequence of the grammar’s rules. And, sentential form is each of the strings
in the derivation of a grammar in programming language
Problem Set
1.
The two mathematical models of language
description are generation and recognition. Describe how each can define the
syntax of a programming language.
= A language recognizer is capable of reading
characters or string in the language and determines whether the programs are in
the specific language and syntactically correct. And a language generator is
used to define the syntax of a language is true or not.
2.
Write EBNF descriptions for the following:
a.
A java class definition header statement
b.
A Java method call statement
c.
A C switch statement
d.
A C union definition
e.
C float literals
a. a java class definition header statement
= <class_head> ® {<modifier>} class <id> [extends class_name]
[implements<interface_name> {, <interface_name>}] <modifier>
® public | abstract | final<class_head> ®
{<modifier>} class <id> [extendsclass_name] [implements<interface_name>
{, <interface_name>}] <modifier> ® public | abstract | final
b. a Java method call statement
= <for> -> for ‘(‘ [[<type>] <id> = <expr> {,
[<type>] <id> = <expr>}] ; [<expr>] ; [<expr>{,
<expr>}] ‘)’ ‘{‘ <stmt_list> ‘}’
= <stmt>
-> switch ( <int expr> ) {
case <int const> : { <stmt> ; }
{ case <int const> : { <stmt> ; }}
[ default : { <stmt> ; } ]
}
d. a C union definition
= <union_defn>
-> union <var_list> <union_identifier>;
<var_list> -> <list_of_data-type specifier> <var>
<list_of_data-type specifier> -> int | float | long |char |
double
<union_identifier> -> <var>
e.
C float literals
= <float-literal> –> <real> <suffix>
| <real> <exponent> <suffix>
|
<integer> <exponent> <suffix>
3. Rewrite the BNF of Example 3.4 to give + precedence over * and force + to be right associative.
= <assign>→<id>=<expr>
<id>→A|B|C
<expr>→< term >*< expr >| <term>
<term>→<term>+<factor>| <factor>
<factor>→(<expr>) | <id>
4. Rewrite the BNF of Example 3.4 to add the ++ and – unary operators of Java.
= <assign> -> <id> = <expr>
<id> -> A | B | C
<expr> -> <expr> + <term> | <term>
<term> -> <term> * <factor> | <factor>
<factor> -> ( <expr> ) | <id> | <id> ++ | <id> - -
5.
Write a BNF description of the Boolean
expressions of Java, including the three operators &&, ||, and ! and
the relational expressions.
= <Boolean_expr> -> <Boolean_expression> || <Boolean_term> | <Boolean_term>
<Boolean_term> -> <Boolean_term> && <Boolean_factor> | <Boolean_factor>
<Boolean_factor> -> id | ! <Boolean_factor> | ( <Boolean_expr> ) | <relation_expr>
<relation_expr> -> id = = id | id != id | id < id | id <= id | id >= id | id > id
= <Boolean_expr> -> <Boolean_expression> || <Boolean_term> | <Boolean_term>
<Boolean_term> -> <Boolean_term> && <Boolean_factor> | <Boolean_factor>
<Boolean_factor> -> id | ! <Boolean_factor> | ( <Boolean_expr> ) | <relation_expr>
<relation_expr> -> id = = id | id != id | id < id | id <= id | id >= id | id > id
An individual point out proper in regards to the diverse equipment and also I prefer these records quite definitely and also you will get rephrasing online to produce work outstanding. In addition, you discuss thus video tutorials to aid individuals.
ReplyDeleteI actually wanna follow it for my website but I need more clearance about this matter. honestly I don't have much more idea about this topic. Can you explane me more please? I got more information at this website
ReplyDeleteA person explain correct with regards to the varied gear as well as I favor these types of information very certainly and you also can get click to explore to create function exceptional. Additionally, a person talk about therefore instructional videos to assist people.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThese programming language can change your profile and can give you best writing goals. Profile writing is not difficult any more so get help y hiring best expert.
ReplyDeletehttp://www.liprofilewriter.com/
Assignment 3 Programming Language Concepts is a great post Written by you. here you write so many thing And this kind of post are really very necessary for the readers. They love this type of post. Visit my site http://www.resumekeywords.biz/the-10-most-successful-resume-buzzwords-2016/.Thank you very much for this post.
ReplyDelete