Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

The executable should be testParser .Please include makefile. Please add as many comments as you can.

Verify the below Grammar is LL(1) or rewrite as needed in an equivalent form

Implement the parser in a separate file (parser.h and parser.c). Implement the main parser function in a separate file main.c: the main function should check for command line arguments, and then call the parser function to build the tree, and then implement recursive traversal to print the tree. Make sure it will check for the EOF token.  The display is just for testing.

Implement the parser in two iterations:

1. Parser1.c : Starting without the parse tree. Have your parses generate error (print the line number and the nature of the problem such as token received and token expected) on the first error and exit, or print OK message upon successful parse.

2. For each non-terminal, use a void function named after the non-terminal. Decide how to pass the token. Be systematic: suppose each function starts with unconsumed token (not matched yet) and returns unconsumed token. The non-LL(1) non-terminals with all-common prefix - implement the shortcut to mate them LL(1) rather than explicitly performing left-factorization

3. Parser2.c : Only after testing and completing the above to satisfaction, modify each parse function to build a subtree, and return its root node. Suppose each function builds just the root and connects its subtrees. Modify the main function to receive the tree built in the parser, and then display it (for testing) using a preorder display. Add declaration file node.h

o do left to right traversal, for each new level use 2 space indentation

o when visiting a node print what the node is and what tokens it has if any, then print its children left to right the same way

o for every token, print token type, instance and line number

 Some hints for tree:

  • every node should have a label consistent with the name of the function creating it
  • every function creates exactly one tree node (or possibly none)
  • the number of children seems as 3 max but it is your decision
  • all syntactic tokens such as () can be thrown away, all other tokens need to be stored in the tree
  • when storing a token, you may need to make a copy depending on your interface

Grammar

->  Start Stop
   ->  { }
    ->  empty | Var ID .
   ->  empty | : ID
     ->  Void() Return(ID);
    ->  empty |
    ->  + | - |
       ->  * |
       ->  / |
       ->  - |
       ->  () | ID | NUMBER 
   ->   
   ->  empty |  
    ->  | | | | |
      ->  Read (ID) ;
     ->  Write () ;
      ->  Iff (              
    ->  While ( )
  ->  ID == ;
      ->  =< | => | = |  > | <  |  !

Example programs (assuming some standard semanticcs)

&short program prints 0
Start {
  Write (0);
} Stop
 
&program echoes input*2
Start
  Var x.
  { Read (x);
     Write (2*x);
  }
Stop
    
&print absolute value
Start {
  Var x: y;
  Read (x);
  Iff (x<0) {
    y == -x;
  }
  Write (y);
} Stop

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9720120
  • Price:- $45

Priced at Now at $45, Verified Solution

Have any Question?


Related Questions in Operating System

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question topic computerized operating systems os are almost

Question: Topic: Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use our phone or tablet. Find articles that describes the diff ...

Research types of operating systems that are currently

Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Explain why you think the choice you made ...

Show all stepssuppose that the following processes arrive

Show all steps Suppose that the following processes arrive for execution at the times indicated. Each process will run the listed amount of time. in answering the questions, use non-preemptive scheduling and base all dec ...

Question research hex editors available for mac os and

Question : Research hex editors available for Mac OS and Linux. Based on the documentation, how easy would validating these tools be? Select at least two hex editors for each OS, and discuss what you would do to validate ...

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

Question description of lasa in this assignment you will

Question: Description of LASA: In this assignment, you will select a real-world operating system (can be for a PC, server, tablet, handheld, or embedded device). You will introduce the operating system and its components ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As