Define orthogonality in the context of programming language design. What is the
ID: 644674 • Letter: D
Question
Define orthogonality in the context of programming language design.
What is the difference between a compiled and an interpreted language? Which
one is Java?
What languages over the alphabet {a, b, c, d} do the following regular expression
represent? Describe in words and give examples. a. (a+b)*
b. (((a b)|(cd))*c)
c. ?*
What is an ambiguous grammar?
What is denotational semantics? What are its strengths and weaknesses as
compared to other approaches to semantics.
What is axiomatic semantics? What are its strengths and weaknesses as compared
to other approaches to semantics.
Compute the weakest precondition for each of the following assignments and
post-conditions
a. a = 2*(b-1)-1{a > 0} b. a=a-1{a>0}
8. Consider the following Language asgn ? id = expr
expr ? term + term | term term ?id|id+id
id ?a|b|c
State terminals and non-terminals.
Is the language below ambiguous or not. Justify.
Note:
To be ambiguous, a grammar must allow two different parse trees, and hence two different left-most derivations, for the same input string. Therefore, at some point in a left-most derivation, there must be choice of which rule to use to expand the left-most non-terminal. If all the rules match a different initial symbol then at most one rule can ever be successfully applied at any given point in the input string. Hence, the grammar must not be ambiguous.
Note: In general, it is quite hard to prove non-ambiguity except for very simple grammars like this one; proving ambiguity (by exhibiting two different parse trees for a single input) is much easier.
Consider a grammar with alphabet a, b and c.
Give a regular expression to generate all strings with only one a.
Give a regular expression to generate all strings with exactly two as.
Check the validity for the following code: {a < 5}
b = a
Explanation / Answer
1. In Programming languages, Orthogonality means simplicity of code.
For example in excel if we want to add 3 cells, we can write A1+A2+A3, But simpler way to do this can be a ready made function like Autosum. You just select the 3 cells and click on Autosum, that will give you correct result. So the second method is orthogonal in nature. That means it has made our work easier.
2. Every programming language uses a Translator to convert its code into machine language. Because computer understands only Binary Language. And we write softwares in High level languages only. So Translators do the work of translating Binary into HLL and vice versa. Interpreted languages use Interpretor as a translator, Compiled Languages use Compiler as a translator. VB is Interpreted language, Java is Compiled language.
4. Ambiguous grammer means the grammer in which one string can be interpreted in two different ways. Ambi means two. For example: x*y can be solved as x multiplied by y or y is a pointer of type x.
5.Denotational Semantics means when we use mathematical structures to explain the expressions of other theoretical languages.
Weakness: It is not easy to understand in comparison to theoretical simple sentences.
Strength: It uses operators, set structures, so solving a problem can be easier and faster.
6.Axiomatic semantics explains the meaning of a program in terms of its properties or Axioms about the program. It explains the step by step process how the program is solved by machine in form of logic.
Strength: It makes program easy to understand in form of logic.
Weakness: It is not so relevant. Just for undersanding in explainatory way it is used otherwise program can be implemented without it also.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.