– 1 – Fall 2015 EECS 338 Assignment 2 Due: Oct. 1st, 2015 G. Ozsoyoglu Concurrent Programming with Semaphores; 140 points (100 pts) 1. Priority-based Searchers/Inserters/Deleters Problem without starvation. Three types of processes, namely, searchers, inserters, and deleters share access to a singly linked list L, and perform search, insert, or delete operations, respectively. The list L does not have duplicate values. a) Searchers merely search the list L, and report success (i.e., item searched is in L) or no-success (i.e., item searched is not in L) to a log file. Hence they can execute concurrently with each other. b) Inserters add new items to the end of the list L, and report success (i.e., item is not in L, and successfully inserted into L) or no-success (i.e., item is already in L, and no insertion takes place) to a log file. Insertions must be mutually exclusive to preclude two inserters from inserting new items at about the same time. However, one insert can proceed in parallel with any number of searches. c) Deleters remove items from anywhere in the list, and report success (i.e., the item is found in L and deleted) or no-success (i.e., item is not in L, and could not be deleted) to a log file. At most one deleter can access the list L at a time, and the deletion must be mutually exclusive with searches and insertions. d) Initial start. Searcher, inserter, and deleter processes are initially launched as follows. A user process that needs a search/insertion/deletion operation to the list L first forks a process, and then, in the forked process, performs an execv into a searcher/ inserter/deleter process. e) Log maintenance. Upon start, each searcher/inserter/deleter writes to a log file, recording the time of insertion, process id, process type (i.e., searcher, inserter, or deleter), and the item that is being searched/inserted/deleted. f) Termination. Upon successful or unsuccessful completion, each searcher/inserter/deleter writes to the same log file, recording the time and the result of its execution. g) Priority-based service between three types. Searchers, inserters, and deleters perform their search, insert, delete operations, respectively, on a priority basis (not on a first-come-first-serve (FCFS) basis) between separate process types (i.e., searchers, inserters, deleters) as follows. Searchers search with the highest priority; inserters insert with the second highest priority (except that one inserter can proceed in parallel with any number of searchers), and deleters delete with the lowest priority. h) FCFS service within a single type. Processes of the same type are serviced FCFS. As an example, among multiple inserters, the order of insertions into L is FCFS. Similarly, among multiple deleters, the order of deletions into L is FCFS. Note that, among searchers, while the start of search among searchers is FCFS, due to concurrent searcher execution, the completions of multiple searchers may not be FCFS. i) Starvation avoidance. In addition to the above priority-based search/insert/delete operations, the following starvation-avoidance rule is enforced. o After 10 consecutive searchers search the list L, if there is at least one waiting inserter or deleter then newly arriving searchers are blocked until (a) all waiting inserters are first serviced FCFS, and, then (b) all waiting deleters are serviced FCFS. Then, both the standard priority-based service between process types and the FCFS service within a process type resume. You are to specify a semaphore-based algorithm to synchronize searcher, inserter and deleter processes. Note:  Explain your algorithm.  Make sure to state any assumptions you make in your solution.  Specify the initial states of your variables and semaphores.  Specify whether your semaphores are binary or nonbinary.  Do not bother specifying algorithms for sequential tasks: simply specify a well-defined function/procedure (i.e., one with well-defined input/output/functional specification). – 2 – (40 pts) 2. Four-of-a-Kind Problem is defined as follows.  There is a deck of 24 cards, split into 6 different kinds, 4 cards of each kind.  There are 4 players (i.e., processes) ??,0≤?≤3; each player can hold 4 cards.  Between each pair of adjacent (i.e., seated next to each other) players, there is a pile of cards.  The game begins by o someone dealing four cards to each player, and putting two cards on the pile between each pair of adjacent players, and o ?0 starting the game. If ?0 has four-of-a-kind, ?0 wins. Whoever gets four-of-a-kind first wins.  Players take turns to play clockwise. That is, ?0 plays, ?1 plays, ?2 plays, ?3 plays, ?0 plays, etc.  Each player behaves as follows. o So long as no one has won, keep playing. o If it is my turn and no one has won:  Check for Four-of-a-Kind. If yes, claim victory. Otherwise discard a card into the pile on the right; pick up a card from the pile on the left; and, check again: If Four-of-a-Kind, claim victory; otherwise revise turn so that the next player plays and wait for your turn.  There are no ties; when a player has claimed victory, all other players stop (when their turns to play come up). You are to specify a semaphore-based algorithm to the Four-of-a-Kind problem. Note:  Explain your algorithm.  Make sure to state any assumptions you make in your solution.  Specify the initial states of your variables and semaphores.  Specify whether your semaphores are binary or nonbinary.  Do not bother specifying algorithms for sequential tasks: simply specify a well-defined function/procedure (i.e., one with well-defined input/output/functional specification). P1 P0 P2 P3 pile 1 pile 2 pile 3 pile 0

– 1 – Fall 2015 EECS 338 Assignment 2 Due: Oct. 1st, 2015 G. Ozsoyoglu Concurrent Programming with Semaphores; 140 points (100 pts) 1. Priority-based Searchers/Inserters/Deleters Problem without starvation. Three types of processes, namely, searchers, inserters, and deleters share access to a singly linked list L, and perform search, insert, or delete operations, respectively. The list L does not have duplicate values. a) Searchers merely search the list L, and report success (i.e., item searched is in L) or no-success (i.e., item searched is not in L) to a log file. Hence they can execute concurrently with each other. b) Inserters add new items to the end of the list L, and report success (i.e., item is not in L, and successfully inserted into L) or no-success (i.e., item is already in L, and no insertion takes place) to a log file. Insertions must be mutually exclusive to preclude two inserters from inserting new items at about the same time. However, one insert can proceed in parallel with any number of searches. c) Deleters remove items from anywhere in the list, and report success (i.e., the item is found in L and deleted) or no-success (i.e., item is not in L, and could not be deleted) to a log file. At most one deleter can access the list L at a time, and the deletion must be mutually exclusive with searches and insertions. d) Initial start. Searcher, inserter, and deleter processes are initially launched as follows. A user process that needs a search/insertion/deletion operation to the list L first forks a process, and then, in the forked process, performs an execv into a searcher/ inserter/deleter process. e) Log maintenance. Upon start, each searcher/inserter/deleter writes to a log file, recording the time of insertion, process id, process type (i.e., searcher, inserter, or deleter), and the item that is being searched/inserted/deleted. f) Termination. Upon successful or unsuccessful completion, each searcher/inserter/deleter writes to the same log file, recording the time and the result of its execution. g) Priority-based service between three types. Searchers, inserters, and deleters perform their search, insert, delete operations, respectively, on a priority basis (not on a first-come-first-serve (FCFS) basis) between separate process types (i.e., searchers, inserters, deleters) as follows. Searchers search with the highest priority; inserters insert with the second highest priority (except that one inserter can proceed in parallel with any number of searchers), and deleters delete with the lowest priority. h) FCFS service within a single type. Processes of the same type are serviced FCFS. As an example, among multiple inserters, the order of insertions into L is FCFS. Similarly, among multiple deleters, the order of deletions into L is FCFS. Note that, among searchers, while the start of search among searchers is FCFS, due to concurrent searcher execution, the completions of multiple searchers may not be FCFS. i) Starvation avoidance. In addition to the above priority-based search/insert/delete operations, the following starvation-avoidance rule is enforced. o After 10 consecutive searchers search the list L, if there is at least one waiting inserter or deleter then newly arriving searchers are blocked until (a) all waiting inserters are first serviced FCFS, and, then (b) all waiting deleters are serviced FCFS. Then, both the standard priority-based service between process types and the FCFS service within a process type resume. You are to specify a semaphore-based algorithm to synchronize searcher, inserter and deleter processes. Note:  Explain your algorithm.  Make sure to state any assumptions you make in your solution.  Specify the initial states of your variables and semaphores.  Specify whether your semaphores are binary or nonbinary.  Do not bother specifying algorithms for sequential tasks: simply specify a well-defined function/procedure (i.e., one with well-defined input/output/functional specification). – 2 – (40 pts) 2. Four-of-a-Kind Problem is defined as follows.  There is a deck of 24 cards, split into 6 different kinds, 4 cards of each kind.  There are 4 players (i.e., processes) ??,0≤?≤3; each player can hold 4 cards.  Between each pair of adjacent (i.e., seated next to each other) players, there is a pile of cards.  The game begins by o someone dealing four cards to each player, and putting two cards on the pile between each pair of adjacent players, and o ?0 starting the game. If ?0 has four-of-a-kind, ?0 wins. Whoever gets four-of-a-kind first wins.  Players take turns to play clockwise. That is, ?0 plays, ?1 plays, ?2 plays, ?3 plays, ?0 plays, etc.  Each player behaves as follows. o So long as no one has won, keep playing. o If it is my turn and no one has won:  Check for Four-of-a-Kind. If yes, claim victory. Otherwise discard a card into the pile on the right; pick up a card from the pile on the left; and, check again: If Four-of-a-Kind, claim victory; otherwise revise turn so that the next player plays and wait for your turn.  There are no ties; when a player has claimed victory, all other players stop (when their turns to play come up). You are to specify a semaphore-based algorithm to the Four-of-a-Kind problem. Note:  Explain your algorithm.  Make sure to state any assumptions you make in your solution.  Specify the initial states of your variables and semaphores.  Specify whether your semaphores are binary or nonbinary.  Do not bother specifying algorithms for sequential tasks: simply specify a well-defined function/procedure (i.e., one with well-defined input/output/functional specification). P1 P0 P2 P3 pile 1 pile 2 pile 3 pile 0

– 1 – Fall 2015 EECS 338 Assignment 2 Due: … Read More...
Attached Files: File Operational Definitions for 670.doc (25.5 KB) Amply armed with all the information you have learned throughout these last 7 weeks (paying special attention to Chapters 11-14), complete a “mini public relations proposal.” Following is a checklist of what is expected in this proposal: 1. Name of the organization and a brief explanation/description (Example: it is a boutique that specializes in selling high-end bridal gowns; it is a nonprofit organization that raises money for children whose parents are wounded veterans, etc.) PLEASE NOTE: No fictitious organizations, please! 2. ONE Overaching Goal (to persuade, inform, educate, etc.) 3. ONE suggestion for the research you plan to conduct. Explain the method (survey, phone interviews, etc.), who you are researching, and why you think this method is most conducive for this communication campaign. 4. ONE behavioral objective (see handouts a) RECALL PLOT: public, level of obtainment, timeframe) b). RECALL that the objective is what you want your target public to do 5. ONE action strategy (RECALL that the strategy is what you are planning to do meet your objective – your gameplan) 6. ONE message strategy (what your message will say) 7. TWO communication tactics 8. ONE technique for measuring whether the objective was met IMPORTANT NOTES: > USE the prsa operational definitions (SEE ATTACHED HANDOUT) > USE subheads for each part of the proposal OR you can just number the components (1-8) > The rubric for this last report is very simple: points will be deducted for each component you do not include or if it is written incorrectly or does not meet all the critiera mapped out in the attached handout.

Attached Files: File Operational Definitions for 670.doc (25.5 KB) Amply armed with all the information you have learned throughout these last 7 weeks (paying special attention to Chapters 11-14), complete a “mini public relations proposal.” Following is a checklist of what is expected in this proposal: 1. Name of the organization and a brief explanation/description (Example: it is a boutique that specializes in selling high-end bridal gowns; it is a nonprofit organization that raises money for children whose parents are wounded veterans, etc.) PLEASE NOTE: No fictitious organizations, please! 2. ONE Overaching Goal (to persuade, inform, educate, etc.) 3. ONE suggestion for the research you plan to conduct. Explain the method (survey, phone interviews, etc.), who you are researching, and why you think this method is most conducive for this communication campaign. 4. ONE behavioral objective (see handouts a) RECALL PLOT: public, level of obtainment, timeframe) b). RECALL that the objective is what you want your target public to do 5. ONE action strategy (RECALL that the strategy is what you are planning to do meet your objective – your gameplan) 6. ONE message strategy (what your message will say) 7. TWO communication tactics 8. ONE technique for measuring whether the objective was met IMPORTANT NOTES: > USE the prsa operational definitions (SEE ATTACHED HANDOUT) > USE subheads for each part of the proposal OR you can just number the components (1-8) > The rubric for this last report is very simple: points will be deducted for each component you do not include or if it is written incorrectly or does not meet all the critiera mapped out in the attached handout.

info@checkyourstudy.com
EGR 140 Scientific Programming Assignment # 7 Spring 2017 Use MATLAB to solve each problem by writing script files; copy and paste the script file AND the results in the Command Window and/or plot in the Figure Window to a WORD document that has your name and section in the headers of each page and the page number in each footer. Edit the output to remove extra lines and empty spaces. The script files SHOULD have comments for easy readability; take a print out of the Word file and staple before submission. Due by 3 PM on April 11, 2017. Write a used-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades: 80 75 91 60 79 89 65 80 95 50 81 Note: The average x_ave (or mean) of a given set of n number x_1,x_2,…..,x_n is given by: x_ave=(x_1+x_2+x_3+⋯+x_n)/n The standard deviation is given by: σ=√((∑_(i=1)^(i=n)▒(x_i-x_ave )^2 )/(n-1)) DO not use built-in functions to calculate the mean and the standard deviation. Write a user-defined function that arranges the digits of a given (positive) number in a row vector in the same order as they appear in the number; the function should also arrange the digits in the decimal part in a different vector. For example, if the number is 2645.12, the vectors should be [2 6 4 5] and [1 2]. The whole number can be from 0 to 10 digits long and the decimal part 0 to 6. Check the validity of the function using a few numbers of your choice. A fenced enclosure consists of a rectangle of length L and width 2R, and a semicircle of radius R, as shown in Figure. The enclosure is to be built to have an area A of 1600 ft2. The cost of the fence is $40 per foot for the curved portion, and $30 per foot for the straight sides. Determine the values of R and L required to minimize the total cost of the fence and the minimum cost using calculus approach. A water tank consists of a cylindrical part of radius r and height h, and a hemispherical top. The tank is to be constructed to hold 500 meter3 of fluid when filled. The cost to construct the cylindrical part of the tank is $300 per square meter of the surface area; the hemispherical part costs $400 per square meter. Determine the radius that results in the least cost and compute the corresponding height and the cost using graphical approach. Verify your results using the calculus approach. A ceramic tile has the design shown in the figure. The shaded area is painted black and the rest of the tile is white. The border line between the red and the white areas follows the equation: y=Asin(x) Determine A such that the area of the white and black colors will be the same.

EGR 140 Scientific Programming Assignment # 7 Spring 2017 Use MATLAB to solve each problem by writing script files; copy and paste the script file AND the results in the Command Window and/or plot in the Figure Window to a WORD document that has your name and section in the headers of each page and the page number in each footer. Edit the output to remove extra lines and empty spaces. The script files SHOULD have comments for easy readability; take a print out of the Word file and staple before submission. Due by 3 PM on April 11, 2017. Write a used-defined function that calculates the average and the standard deviation of a list of numbers. Use the function to calculate the average and the standard deviation of the following list of grades: 80 75 91 60 79 89 65 80 95 50 81 Note: The average x_ave (or mean) of a given set of n number x_1,x_2,…..,x_n is given by: x_ave=(x_1+x_2+x_3+⋯+x_n)/n The standard deviation is given by: σ=√((∑_(i=1)^(i=n)▒(x_i-x_ave )^2 )/(n-1)) DO not use built-in functions to calculate the mean and the standard deviation. Write a user-defined function that arranges the digits of a given (positive) number in a row vector in the same order as they appear in the number; the function should also arrange the digits in the decimal part in a different vector. For example, if the number is 2645.12, the vectors should be [2 6 4 5] and [1 2]. The whole number can be from 0 to 10 digits long and the decimal part 0 to 6. Check the validity of the function using a few numbers of your choice. A fenced enclosure consists of a rectangle of length L and width 2R, and a semicircle of radius R, as shown in Figure. The enclosure is to be built to have an area A of 1600 ft2. The cost of the fence is $40 per foot for the curved portion, and $30 per foot for the straight sides. Determine the values of R and L required to minimize the total cost of the fence and the minimum cost using calculus approach. A water tank consists of a cylindrical part of radius r and height h, and a hemispherical top. The tank is to be constructed to hold 500 meter3 of fluid when filled. The cost to construct the cylindrical part of the tank is $300 per square meter of the surface area; the hemispherical part costs $400 per square meter. Determine the radius that results in the least cost and compute the corresponding height and the cost using graphical approach. Verify your results using the calculus approach. A ceramic tile has the design shown in the figure. The shaded area is painted black and the rest of the tile is white. The border line between the red and the white areas follows the equation: y=Asin(x) Determine A such that the area of the white and black colors will be the same.

checkyourstudy.com Whatsapp +919891515290
ME4575/5575 Renewable and Alternative Energy Fall 2015 Project 1 In this project, you will design a two piston Stirling engine (as in the example given in the class) of 1 kW power. The engine will be operated at TH=650 0C. The waste energy will be rejected at the temperature of TC=40 0C. The objective of the design is to maximize the efficiency and minimize the system weight. For the given temperature ratio, you have to select and optimize the piston diameter and piston stroke. The weight is proximately equal to the hot and cold piston volume multiplying by steel density. You can use Excel spreadsheet (or other engineering software) to create a Stirling modeling file to iterate on the piston diameter and stroke until the best combination of efficiency and weight (cost) is achieved. The project report has to contain a short introduction, technical description of the problem, details of analyses, and final conclusion of the design (size, weight, and efficiency).

ME4575/5575 Renewable and Alternative Energy Fall 2015 Project 1 In this project, you will design a two piston Stirling engine (as in the example given in the class) of 1 kW power. The engine will be operated at TH=650 0C. The waste energy will be rejected at the temperature of TC=40 0C. The objective of the design is to maximize the efficiency and minimize the system weight. For the given temperature ratio, you have to select and optimize the piston diameter and piston stroke. The weight is proximately equal to the hot and cold piston volume multiplying by steel density. You can use Excel spreadsheet (or other engineering software) to create a Stirling modeling file to iterate on the piston diameter and stroke until the best combination of efficiency and weight (cost) is achieved. The project report has to contain a short introduction, technical description of the problem, details of analyses, and final conclusion of the design (size, weight, and efficiency).

1 IN2009: Language Processors Coursework Part 3: The Interpreter Introduction This is the 3rd and final part of the coursework. In the second part of the coursework you created a parser for the Moopl grammar which, given a syntactically correct Moopl program as input, builds an AST representation of the program. In Part 3 you will develop an interpreter which executes Moopl programs by visiting their AST representations. For this part of the coursework we provide functional code (with limitations, see below) for parsing, building a symbol table, type checking and variable allocation. Marks This part of the coursework is worth 12 of the 30 coursework marks for the Language Processors module. This part of the coursework is marked out of 12. Submission deadline This part of the coursework should be handed in before 5pm on Sunday 9th April 2017. In line with school policy, late submissions will be awarded no marks. Return & Feedback Marks and feedback will be available as soon as possible, certainly on or before Wed 3rd May 2017. Plagiarism If you copy the work of others (either that of fellow students or of a third party), with or without their permission, you will score no marks and further disciplinary action will be taken against you. Group working You will be working in the same groups as for the previous parts of the coursework except where group changes have already been approved. Submission: Submit a zip archive (not a rar file) of all your source code (the src folder of your project). We do not want the other parts of your NetBeans project, only the source code. Note 1: Submissions which do not compile will get zero marks. Note 2: You must not change the names or types of any of the existing packages, classes or public methods. 2 Getting started Download either moopl-interp.zip or moopl-interp.tgz from Moodle and extract all files. Key contents to be aware of: • A fully implemented Moopl parser (also implements a parser for the interpreter command language; see below). • A partially implemented Moopl type checker. • Test harnesses for the type checker and interpreter. • A directory of a few example Moopl programs (see Testing below). • Folder interp containing prototype interpreter code. The type-checker is only partially implemented but a more complete implementation will be provided following Session 6. That version is still not fully complete because it doesn’t support inheritance. Part d) below asks you to remove this restriction. The VarAllocator visitor in the interp package uses a simple implementation which only works for methods in which all parameter and local variable names are different. Part e) below asks you to remove this restriction. The three parts below should be attempted in sequence. When you have completed one part you should make a back-up copy of the work and keep it safe, in case you break it in your attempt at the next part. Be sure to test old functionality as well as new (regression testing). We will not assess multiple versions so, if your attempt at part d) or e) breaks previously working code, you may gain a better mark by submitting the earlier version for assessment. c) [8 marks] The Basic Interpreter: complete the implementation of the Interpreter visitor in the interp package. d) [2 marks] Inheritance: extend the type-checker, variable allocator and interpreter to support inheritance. e) [2 marks] Variable Allocation: extend the variable allocator to fully support blockstructure and lexical scoping, removing the requirement that all parameter and local variable names are different. Aim to minimise the number of local variable slots allocated in a stack frame. Note: variable and parameter names declared at the same scope level are still required to be different from each other (a method cannot have two different parameters called x, for example) and this is enforced by the existing typechecking code. But variables declared in different blocks (even when nested) can have the same name. Exceptions Your interpreter will only ever be run on Moopl code which is type-correct (and free from uninitialised local variables). But it is still possible that the Moopl code contains logical errors which may cause runtime errors (such as null-reference or array-bound errors). Your interpreter should throw a MooplRunTimeException with an appropriate error message in these cases. The only kind of exception your interpreter should ever throw is a MooplRunTimeException. 3 Testing The examples folder does not contain a comprehensive test-suite. You need to invent and run your own tests. The document Moopl compared with Java gives a concise summary of how Moopl programs are supposed to behave. You can (and should) also compare the behaviour of your interpreter with that of the online tool: https://smcse.city.ac.uk/student/sj353/langproc/Moopl.html (Note: the online tool checks for uninitialised local variables. Your implementation is not expected to do this.) To test your work, run the top-level Interpret harness, providing the name of a Moopl source file as a command-line argument. When run on a type-correct Moopl source file, Interpret will pretty-print the Moopl program then display a command prompt (>) at which you can enter one of the following commands: :quit This will quit the interpreter. :call main() This will call the top-level proc main, interpreted in the context defined by the Moopl program. (Any top-level proc can be called this way). :eval Exp ; This will evaluate expression Exp, interpreted in the context defined by the Moopl program, and print the result. Note the required terminating semi-colon. Testing your Expression visitors To unit-test your Exp visit methods, run the top-level Interpret harness on a complete Moopl program (though it can be trivial) and use the :eval command. For example, to test your visit methods for the Boolean-literals (ExpTrue and ExpFalse), you would enter the commands > :eval true ; > :eval false ; which should output 1 and 0, respectively. For the most basic cases, the Moopl program is essentially irrelevant (a single top-level proc with empty body may be sufficient). For other cases you will need to write programs containing class definitions (in order, for example, to test object creation and method call). Testing your Statement visitors To unit-test your Stm visit methods, write very simple Moopl programs, each with a top-level proc main() containing just a few lines of code. Run the top-level Interpret harness on these simple programs and enter the command > :call main() You will find a few examples to get you started in the folder examples/unittests. As for the Exp tests, simple cases can be tested using Moopl programs with just a main proc but for the more complex tests you will need to write Moopl programs containing class definitions. 4 Grading criteria Solutions will be graded according to their functional correctness, and the elegance of their implementation. Below are criteria that guide the award of marks. 70 – 100 [1st class] Work that meets all the requirements in full, constructed and presented to a professional standard. Showing evidence of independent reading, thinking and analysis. 60 – 69 [2:1] Work that makes a good attempt to address the requirements, realising all to some extent and most well. Well-structured and well presented. 50 – 59 [2:2] Work that attempts to address requirements realising all to some extent and some well but perhaps also including irrelevant or underdeveloped material. Structure and presentation may not always be clear. 40 – 49 [3rd class] Work that attempts to address the requirements but only realises them to some extent and may not include important elements or be completely accurate. Structure and presentation may lack clarity. 0 – 39 [fail] Unsatisfactory work that does not adequately address the requirements. Structure and presentation may be confused or incoherent.

1 IN2009: Language Processors Coursework Part 3: The Interpreter Introduction This is the 3rd and final part of the coursework. In the second part of the coursework you created a parser for the Moopl grammar which, given a syntactically correct Moopl program as input, builds an AST representation of the program. In Part 3 you will develop an interpreter which executes Moopl programs by visiting their AST representations. For this part of the coursework we provide functional code (with limitations, see below) for parsing, building a symbol table, type checking and variable allocation. Marks This part of the coursework is worth 12 of the 30 coursework marks for the Language Processors module. This part of the coursework is marked out of 12. Submission deadline This part of the coursework should be handed in before 5pm on Sunday 9th April 2017. In line with school policy, late submissions will be awarded no marks. Return & Feedback Marks and feedback will be available as soon as possible, certainly on or before Wed 3rd May 2017. Plagiarism If you copy the work of others (either that of fellow students or of a third party), with or without their permission, you will score no marks and further disciplinary action will be taken against you. Group working You will be working in the same groups as for the previous parts of the coursework except where group changes have already been approved. Submission: Submit a zip archive (not a rar file) of all your source code (the src folder of your project). We do not want the other parts of your NetBeans project, only the source code. Note 1: Submissions which do not compile will get zero marks. Note 2: You must not change the names or types of any of the existing packages, classes or public methods. 2 Getting started Download either moopl-interp.zip or moopl-interp.tgz from Moodle and extract all files. Key contents to be aware of: • A fully implemented Moopl parser (also implements a parser for the interpreter command language; see below). • A partially implemented Moopl type checker. • Test harnesses for the type checker and interpreter. • A directory of a few example Moopl programs (see Testing below). • Folder interp containing prototype interpreter code. The type-checker is only partially implemented but a more complete implementation will be provided following Session 6. That version is still not fully complete because it doesn’t support inheritance. Part d) below asks you to remove this restriction. The VarAllocator visitor in the interp package uses a simple implementation which only works for methods in which all parameter and local variable names are different. Part e) below asks you to remove this restriction. The three parts below should be attempted in sequence. When you have completed one part you should make a back-up copy of the work and keep it safe, in case you break it in your attempt at the next part. Be sure to test old functionality as well as new (regression testing). We will not assess multiple versions so, if your attempt at part d) or e) breaks previously working code, you may gain a better mark by submitting the earlier version for assessment. c) [8 marks] The Basic Interpreter: complete the implementation of the Interpreter visitor in the interp package. d) [2 marks] Inheritance: extend the type-checker, variable allocator and interpreter to support inheritance. e) [2 marks] Variable Allocation: extend the variable allocator to fully support blockstructure and lexical scoping, removing the requirement that all parameter and local variable names are different. Aim to minimise the number of local variable slots allocated in a stack frame. Note: variable and parameter names declared at the same scope level are still required to be different from each other (a method cannot have two different parameters called x, for example) and this is enforced by the existing typechecking code. But variables declared in different blocks (even when nested) can have the same name. Exceptions Your interpreter will only ever be run on Moopl code which is type-correct (and free from uninitialised local variables). But it is still possible that the Moopl code contains logical errors which may cause runtime errors (such as null-reference or array-bound errors). Your interpreter should throw a MooplRunTimeException with an appropriate error message in these cases. The only kind of exception your interpreter should ever throw is a MooplRunTimeException. 3 Testing The examples folder does not contain a comprehensive test-suite. You need to invent and run your own tests. The document Moopl compared with Java gives a concise summary of how Moopl programs are supposed to behave. You can (and should) also compare the behaviour of your interpreter with that of the online tool: https://smcse.city.ac.uk/student/sj353/langproc/Moopl.html (Note: the online tool checks for uninitialised local variables. Your implementation is not expected to do this.) To test your work, run the top-level Interpret harness, providing the name of a Moopl source file as a command-line argument. When run on a type-correct Moopl source file, Interpret will pretty-print the Moopl program then display a command prompt (>) at which you can enter one of the following commands: :quit This will quit the interpreter. :call main() This will call the top-level proc main, interpreted in the context defined by the Moopl program. (Any top-level proc can be called this way). :eval Exp ; This will evaluate expression Exp, interpreted in the context defined by the Moopl program, and print the result. Note the required terminating semi-colon. Testing your Expression visitors To unit-test your Exp visit methods, run the top-level Interpret harness on a complete Moopl program (though it can be trivial) and use the :eval command. For example, to test your visit methods for the Boolean-literals (ExpTrue and ExpFalse), you would enter the commands > :eval true ; > :eval false ; which should output 1 and 0, respectively. For the most basic cases, the Moopl program is essentially irrelevant (a single top-level proc with empty body may be sufficient). For other cases you will need to write programs containing class definitions (in order, for example, to test object creation and method call). Testing your Statement visitors To unit-test your Stm visit methods, write very simple Moopl programs, each with a top-level proc main() containing just a few lines of code. Run the top-level Interpret harness on these simple programs and enter the command > :call main() You will find a few examples to get you started in the folder examples/unittests. As for the Exp tests, simple cases can be tested using Moopl programs with just a main proc but for the more complex tests you will need to write Moopl programs containing class definitions. 4 Grading criteria Solutions will be graded according to their functional correctness, and the elegance of their implementation. Below are criteria that guide the award of marks. 70 – 100 [1st class] Work that meets all the requirements in full, constructed and presented to a professional standard. Showing evidence of independent reading, thinking and analysis. 60 – 69 [2:1] Work that makes a good attempt to address the requirements, realising all to some extent and most well. Well-structured and well presented. 50 – 59 [2:2] Work that attempts to address requirements realising all to some extent and some well but perhaps also including irrelevant or underdeveloped material. Structure and presentation may not always be clear. 40 – 49 [3rd class] Work that attempts to address the requirements but only realises them to some extent and may not include important elements or be completely accurate. Structure and presentation may lack clarity. 0 – 39 [fail] Unsatisfactory work that does not adequately address the requirements. Structure and presentation may be confused or incoherent.

checkyourstudy.com Whatsapp +919911743277