# must be excel in Grammar and infinite Prgramming

must be excel in Grammar and infinite Prgramming

must be excel in Grammar and infinite Prgramming
(10 points) Create a NFA and a regular expression for a Floating point literal in GO LANG. HOw would a DFA be different? (5 points) Write 5 possible strings of size 6 and the way you get there from the starting state S. S → A | BC | Ca → aB | b | cBB → cB | CBb → aBA | b | daB (5 points) Write the smallest if-ifelse-else statement that can be created with Modula 2. (15 points) Given the following Grammar and the right sentential form draw a parse tree. S → AbB | bAc → Ab | aBB → Ac | cBb | c a) aAccbcBb b) baBcBbbbc c)accbcccbb (5 points) Draw the Von Neumann architecture and detail how each portion affects in the compilations process? (5 points) Draw, label and describe the processes for compilation and for interpretation, describe the differences between the two (5 points) Create a state diagram of multi line comments in C (10 points) Count the total number of identifiers in the following Go Lang Code block, AND list the unique ones: package main import “fmt” func sum(nums …int) { fmt.Print(nums, ” “) total := 0 for _, num := range nums { total += num } fmt.Println(total) } func main() { sum(1, 2) sum(1, 2, 3) nums := []int{1, 2, 3, 4} sum(nums…) } Page 2 of 3 60 points Programming Language Concepts Test 1 July 1st, 2019 (10 points) Lexically analyze the following code segment. Give the total number of lexemes. State the token provided for each value ( reserved words, assignment operators, identities, etc. ) int currSum = 0; int oddCount = 0; for(int i = 1; currSum + i <= num; i+=2) { currSum += i; oddCount++; } (10 points) Show the left most derivation and a parse tree for the following GO LANG code: for i, s := range a { // type of i is int // type of s is string // s == a[i] g(i, s) } Remember syntax analysis is done on tokens and not lexemes. You may use lexemes of special symbolsas their token. (10 points) Show the left most derivation and a parse tree for the following RUST code: struct Point {x: i32, y: i32} let p = Point {x: 10, y: 11}; Remember syntax analysis is done on tokens and not lexemes. You may use lexemes of special symbolsas their token. (10 points) Write the formal definition of a language that has and odd number of a’s, followed by an even number of c’s, followed by a number of e’s equal to the number of a’s plus c’s. Page 3 of 3 40 points 1 (5 points) The following EBNF rules describe the syntax of decimal literals in Ada. Draw a state diagram that represents the following rule set. [. ] [] {[underline] } E [+ | -] 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 _ (5 points) Name the 4 main evaluations of a programming language? Describe in detail three other evaluations and how they tie into the 4. (5 points) Convert the lexical analyzer given in Section 4.2 to Java and modify it to recognize the following list of reserved words and return their respective token codes: for, 30; if, 31; else, 32; while, 33; do, 34; int, 35; float, 36; switch, 37. 15 points (5 points) Perform the Pairwise disjointness test for the following Grammar rules: A → aB | b | cBB B → aB | bA | BBb C → aaA | b | caB | aB (5 points) Perform the Pairwise disjointness test for the following Grammar rules: S → aSb | bAA A → b{aB} | a | Bc B → aB | c (15 points) Given the following Grammar and the right sentential form draw a parse tree and show the phrases, simple phrases and handle. S → AbB | bAc → Ab | aBB → Ac | cBb | c aAccbcBb b) baBcBbbbc c)accbcccbb 15 points (10 points) Show a complete parse, including the parse stack contents, input string, and action for the strings id ∗ (id) + id id + (id + id) id + id − id (5 points) Draw the Von Neumann architecture and detail how each portion affects in the compilations process? (5 points) Draw, label and describe the processes for compilation and for interpretation, describe the differences between the two (10 points) Name, describe, and define two (2) different programming paradigm ( Not Including the one provided )s two (2) languages that are included in each. For Example: Declarative Programming A language that expresses the logic of a computation without describing its control flow. This is a language that contrast imperative programming and implements algorithms in explicit steps. Declarative programming often considers programs as theories of formal logic and computations as deductions in that logic sequence. Languages SQL (Database Query Language), Analytica (Declarative Modeling Langugae) 20 points (5 points) Create a visual representation ( Linked List Style ) of how the following program is stored in LISP: (defun factorial (N) “Compute the factorial of N.” (if (= N 1) 1 (* N (factorial (- N 1))))) (5 points) Show the steps in processing the value of factorial(5) : (5 points) Lexically analyze the following code segment. Give the total number of lexemes. State the token provided for each value ( reserved words, assignment operators, identities, etc. ) int currSum = 0; int oddCount = 0; for(int i = 1; currSum + i <= num; i+=2) { currSum += i; oddCount++; } (5 points) Perform the Pairwise disjointness test for the following Grammar rules: S → aSb | bAA A → b{aB} | a | Bc B → aB | c (5 points) Find the weakest precondition: = 3 / b;b = a - 3; if ( b > a ){ b++; } else { b = 3 * b; } { b > 0} (10 points) Prove Correctness: { n >= 0 } k = n; f = 1; while( k > 0 ){ f = f * k++; } { f = n! } { x > 0 } while( x < 10 ){ x = x + 1; } { x >= 10 } 