0% found this document useful (0 votes)
14 views23 pages

PPL 2mrks

The document defines key programming concepts such as lexemes and tokens, syntax and semantics, and the functions of lexical analysis. It also discusses various programming languages, parsing techniques, data types, and programming paradigms, including object-oriented and functional programming. Additionally, it covers specific programming constructs like associative arrays, guarded statements, and overloaded methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
14 views23 pages

PPL 2mrks

The document defines key programming concepts such as lexemes and tokens, syntax and semantics, and the functions of lexical analysis. It also discusses various programming languages, parsing techniques, data types, and programming paradigms, including object-oriented and functional programming. Additionally, it covers specific programming constructs like associative arrays, guarded statements, and overloaded methods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 23
Define the terms Lexeme and Tokens. Define syntax and semantics. Explain the functions of lexical analysis phase. Show the various programming languages in early. Differentiate Top down parsing and Bottom up parsing. What are the design issues of names? List out the primitive data types. Define associative arrays. Differentiate record type and union type. Define guarded statement. Give example of mixed mode assignment. What is the difference between procedure and functions? Explain the overloaded methods. Differentiate semaphore and Monitor. Explain the different levels of concurrency. What are the design issues of OOP languages? Explain event delegation model in Java. What are the applications of functional programming? Differentiate functional programming and logical programming. Define the Logic Programming Languages. Give the features of ML Programming Languages. What is Programming Paradigm? What is beta conversion? Discuss the features of OOP. Define static binding and dynamic binding. 1.Define the terms token and lexeme The lexeme of a programming language include its - numeric literals - operators - and special words, among others. + (e.g., *, sum, begin) A lexeme is the lowest level syntactic unit of a language: - for simplicity’s sake, formal descriptions of the syntax of programming languages often do not include description of them - However the description of lexemes can be given by a lexical specification which is usually separate from the syntactic description of the language. - A token is a category of lexemes (e.g., identifier) - a token may have only a single lexeme - For example, the token for the arithmetic operator symbol +, which may have the name plus_op, has just one possible lexeme. - alexeme of a token can also be called an instance of the token Bostne syntax and semantics. Syntax: It refers to the rules and regulations for writing any statement in a programming language like C/C++. It does not have to do anything with the meaning of the statement. A statement is syntactically valid if it follows all the rules. It is related to the grammar and structure of the language. Semantics: It refers to the meaning associated with the statement in a programming language. It is all about the meaning of the statement which interprets the program easily. Errors are handled at runtime. j eploin the Jon cons DE Rexical oratuite ae K Read Vp Chonracter from cowne pregnam >K Diedug the ren Ge ints Vatich tokens [He kenizoctiog) - * Remove White sae theraaters -R Remove coPwerta , (sit) x Tt Pet idonsi-fy token no ore yebel table Bait: geneva fexjcal Locerts - 2.Show the various program ling languages in early. 2000 ~ ActionScript 2001 — cH 2001-D 2002 - Scratch 2003 - Groovy 2003 - Scala 2005 - Ft 2008 — Holy 2006 — PowerShell 2007 — Clojure 2008 - Nim 2009 - Go 2011 - Dart 2011 - Kotin 2012 ~ Jia 2012 - TypeSeript 2012 - Eim 2012 - Elixir 2014 — Swit 2015 - Rust. 2015 — Raku 2019 ~ Bosque 2021 — Microsoft Power Fx 1990 - Haskell +1990 ~ Python 41991 - Visual Basic 1993 - Lua 1993-R 41994 — CLOS (pant of ANSI Common Lisp) 1995 - Ruby 1995 - Ada 95 1995 - Java 1995 — Delphi (Object Pascal) 1995 - JavaScript 1995 - PHP 1996 - OCam! 4997 — Rebol 41980 — C++ (as C with classes, renamed in 1983) 1983 ~ Ada 1984 — Common Lisp 1984 — MATLAB 11984 — dBase Ill, dBase Ill Plus (Clipper and FoxPro as FoxBASE) 1985 — Eitte! 11986 - Objective-C 4986 — LabVIEW (visual programming language) 1986 - Eriang 1987 - Perl 1988 — PIC (markup language) 1988 - Tel 41988 — Wolfram Language (as part of Mathematica, only got a separate name in June 2013) 1989 — FL (Backus) 1967 - BCPL (forerunner to B) 1968 Logo 11969 — B (forerunner to C) 1970 - Pascal 1970— Forth 1972-C 1972 Smalltalk 1972 - Prolog 4973-ML 1975 - Scheme 41978 — SQL (a query language, later extended) on 5.Differentiate Top down parsing and Bottom up parsing Key Top Down Parsing Bottom Up Parsing Strategy Top-down approach starts evaluating the parse tree from the top and move downwards for parsing other nodes. Top-down parsing attempts to find the left Bottom-up approach starts evaluating the parse tree from the lowest level of the tree and move upwards for parsing the node. Bottom-up parsing attempts to reduce the construct a string. Attempt most derivation fora input string to first symbol given string. of the grammar. is il Top-down parsing uses Bottom-up parsing uses Derivation Type leftmost derivation. the rightmost derivation. Top-down parsing Bottom-up parsing searches for a production | searches for a production Objective tule to be used to tule to be used to reduce a string to get a starting symbol of grammar. 6. Whar ote the clewiga RAWLS Ay noes ° The SOS Ow ee ia + eerdayn ’ ASAUL Ry rames! / Are Names Core CRIVLE NE? - + Aw fre Apical woorvals pt. 7 he | Loreqnoge. Seacsumeeh pao ws On Rayurordls ? ist out the primitive data types. + Pfifiiitive data types - includes byte, short, int, long, float, double, boolean and char A Primitive data type specifies the size and type of variable values, and it has no additional methods. Data Type Size Description byte 1 byte Stores whole numbers from -128 to 127 short 2 bytes Stores whole numbers from -32,768 to 32,767 int 4 bytes Stores whole numbers from -2,147,483,648 to 2,147,483,647 long 8 bytes Stores whole numbers from 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 float 4 bytes Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits double 8 bytes Stores fractional numbers. Sufficient for storing 15 decimal digits boolean 1 bit Stores true or false values char 2 bytes Stores a single character/letter or ASCII values 7.Define associative arrays. ssociative arrays are arrays that use named keys that you assign to them. There are two ways to create an PHP associative array: gage = array("Peter"=>"35", “Ben"=>"37", “Joe"=>"43"); OR $age['Peter'] = "35"; $age['Ben'] = "37"; gage['Joe'] = "43"; © Riffarantiasa secant umes and snmian me 8. Differentiate record type and union type. The Union type is used to specify a value that can have one of several possible types, whereas the Record type is used to create an object type with a fixed set of keys and values. This is the difference between the Record type and the Union type in TypeScript. 9.Define guarded statement 10 guarded statement is a programming construct that helps manage concurrent access to shared resources, preventing race conditions and maintaining data integrity in multi-threaded or multi-tasking environments. 10. Give example of mixed mode assignment. Mixed-mode assignment refers to a situation in programming where values of different data types are assigned to each other in an expression, and the language's type conversion rules determine how the assignment is carried out. Mixed-mode assignments are common in programming languages that perform implicit type conversions or coercions to handle operations involving different data types. However, it's important to be aware of the type conversion rules in your chosen programming language to avoid unexpected results or errors. Here's an example in Python: integer_value = 42 float_value = 3.14 result = integer_value + float_value # Mixed-mode addition print(result) # Output: 45.14 exe cursed 1 order, Abed tar dome Computasie Ti) Funciens tan be coded prem Ii Procedure Can ne proccss: Anom ion Pye slamaphawe. 4 Monit vss " Moto y. Mutual exclttsien sneccls | Mukti? Madtal eoccul ts be ode taplictty. Mutual exctuwon is automo e | W) boned Voriches =) ery vaxialis ons qpobol ts hickden | au prsiendes ii) Accom be Aberec Veviabes i) Access fo menor Aa prrctected ala nek ete . i, wy vw agi s ee @ Diggownr dees ok_ Ganeurerencays i hk Ttbrurckim Level: Exc curing 2 er) more machine shubructions 2. Abobemens ewe +: Extuuting 2 @0_ more hoped Sanger to Fmubtorerily 3. Unis bed Executing 2 cor) ore dlubpremq norm. vhs Simullanaeudly a eee i defined as a method of problem solving and an approach to programming language design. Various types of programming paradigm are - 1. Imperative or procedural programming Object oriented programming, 3. Functional programming 4. Logie programming, (0.10 Give the features of ML programming language. ML isa static scoped functional programming language. The syntax of ML programming language is more like imperative programming language. Everything is built from expressions. It provides for structured values such as lists, tuples and so on. he applications of functional programming ? main domain of functional programming language is artificial intelligence This language is used for building expert systems, knowledge representai machine learning, natural language processing, modeling speech and vi Funetional la z¢ is also used for building mathematical software. Logic Programming only. It is also In this paradigm we express computation in terms of mathematical logi called as rule based programming approach. Principio of Programming Languages 8 38 Rules are specified in no special order Ie supports for cleclaratlve ip ming approach, In this approach how the computations take place is explained in whieh the basic e The logic paradigm focuses on predicate le Example of logic programming is prolog. 4 What is beta conversion? ‘Ans. : The basic operation in lambda calculus is the application of expression. For example (x(x + 1))(3) is equal to (3 + 1). Thus we are substituting the value 3 for the variable x and throwing the lambda away. This is called beta conversion. Thus beta conversion is a process of simplifying the expression and this removing the lambdas. Tams pa a a Objet outnied Praqwamming. (Cor) ia A peering we Organized enveund woth” aalha ho ae Trotwsres: 25 Static Binding (AKA Early Binding): the compiler uses the type of variables to do the binding at a compile (link) time — Dynamic Binding (AKA Late Binding): the decision is made at run time based on the type of the actual values Q.16 Explain event delegation model in Java ? Ans. : The event delegation model is based on - The event classes, the event listeners, event objects. There are three participants in event delegation model in Java - o Event source - The class which broadcasts the events o Event listeners - The classes which receive notifications of events © Event object - The class object which describes the event. g What are the design issues of OOP languages ? 1) 2) 3) 4) 5) 6) Exclusivity of objects Are subclasses subtypes ? Type checking and polymorphism Single and multiple inheritance Allocation and deallocation of objects Static and dynamic binding. ae eS eee eee ae oo a 4. Functional Programming Vs. Logical Programming Sr. No. Functional ae cael ree 1 Functional programming uses functions. Logical programming uses predicates. 2 The functions can return a value. Predicate cannot return a value. aa can be true or false. 3, In functional programming, the variable In logic programming, a variable does not denotes the concrete value. need to refer to concrete value. 4 Functional programming is normally used Logical programming is normally used for for conielie reasoning. peace knowledge. 5. Ex amples - ML, HASKELL are functional Example - PROLOG i isa logical programming programming languages. language. — ae ee .7_ Explain overloaded methods. is. : Overloading is a mechanism in which we can use many methods having the same function name but can pass different number of parameters or different types of parameter. For example, int sum(int a,int b); ‘double sum(double a,double b); int sum(int a,int b,int c);

You might also like