Application Domains : Business Processing Scientific System Control Publishing
Application Domains : Business Processing Scientific System Control Publishing
Application Domains : Business Processing Scientific System Control Publishing
Application domains
Business Processing
Scientific
System Control
Publishing
Pragmatic Constraints in PL design
1. Architecture
VON-Neumann architecture, RISC,CISC etc
2. Technical Settings
Operating system, environment, System S\W
3. Standards
Standardization of any language is very time consuming
process. There are several organizations involved
in the process which give their comments and look
all the technical aspects.
4. Legacy system
A new developed must support the required functionality
of old version’s language.
Qualities
Simplicity & Readability
• Easy to write
• Should intelligible & easy to read by average
people
• Easy to learn & to teach
Clarity about binding
A language element bounded to the property at the
time property is defined for it.
Major binding times-
1. Language definition time
when the language is defined, basic data types
are bounded to a special tag called Reserved
words.
2. Language implementation time
When the compiler/interpreter for the language is written,
values are bound to machine representation.
e.g. size of int (C lang) determine at this level.
4. Compile time-
When programs are compiled, statements and
expressions are bounded to equivalent machine
instruction code.
5. Program Load time-
When Loader load machine code static variables are
assigned to fixed memory location and run time stack is
allocated to a block of memory.
6. Program run time-
Variables bound to the values at the run time.
Reliability-
Does the program behave the same way every times
it is run with the same input data?
Does it behave same way when it run on diff
platforms?
Support
Easily availability of compiler, documentation (manual)
and IDE . Any one should install it.
Orthogonality-
A language is said to be orthogonal if its statements &
features are built upon a small, mutually independent
set of primitive operation. More orthogonal a language,
fewer exceptional rules are needed for writing the
correct program.
(unit 2) Syntax
Form of a program called syntax and meaning of a program is
called semantics.
Levels of grammar-
1- regular
2- context free
3- context sensitive
4- Unrestrictive.
Context free language- its has a set of production P, a set of
terminal symbol T, a set of non-terminal symbol N and Start symbol S.
One form of CFG called Backur Naur Form (BNF).
BNF-
A production is a rule for rewriting, that can be applied to a string of
symbols called a sentential form.
The nonterminal A can be replaced by w in sentential form.
Symbol A called left hand side and w is called right hand side of
production.
Eg.
BinaryDigit 0
BinaryDigit 1
This pair define that a binaryDigit either 0 or 1.
Non-terminal symbols are symbols that appear on the left hand side
of production and Terminal are the symbols that appear in the
production.
binaryDigit could be expressed in below form.
binaryDigit 0 | 1
BNF grammer Ginteger, which define the grammatical category
Integer as a sequence of decimal digits.
Integer Digit | Integer Digit
Digit 0|1|2|3|4|5|6|7|8|9
Derivations.
Determine 352 is an Integer or not/
Develop the grammar for it-
1- 1st write down the strat symbol integer.
2- Replace the Integer with the string Integer Digit, which is the second
alternative of first production rules.
3- Substitute the Integer Digit for Integer, and produce the string Integer
Digit Digit.
4- substitute Digit for Integer, this time using the first alternative in the
first production rule.
5- Substitute 3 as a particular kind of Digit using the second production
rules.
6- Substitute the 5 for the next Digit in this string,
7- substitute the 2 for digit in this string.
Integer Digit
Ambiguous Grammar-
Specification that can be interpreted two or more different ways.
“A grammar is ambiguous if its language contains at least one string
with two distinct pares trees”
If ambiguity is exist, that can be resolved by establishing conventions
that rule out all but one parse tree for each string.
E - E
E E 1
1 0
Construct second parse tree…………………….(assign)
Dangling-Else Ambiguity-
If (x<0)
if (y<0) y=y-1;
else y=0;
Here grammar permits the else clause to be attached to either if.
Issue- which if the else should be attached?
How to resolve ?
Every else clause is associated with the textually closest preceding
unmatched if Statement. If a different attachment desired,
programmer must use {}.
CLite Grammer