Please provide code in C language. I need code for staticsemantic.c and staticsemantic.h Please provide code according to local option: You may process all variables using local scope rules, or process variables before program as global and all other variables as local. Software support Implement a stack adapter according to the following Stack item type is String or whatever was your identifier token instance - the stack will process identifiers. You may also store line number or the entire token for more detailed error messaging You can assume no more than 100 items in a program and generate stack overflow if more Interface void push(String); just push the argument on the stack void pop(void); just remove int find(String); the exact interface may change, see below find the first occurrence of the argument on the stack, starting from the top and going down to the bottom of the stack return the distance from the TOS (top of stack) where the item was found (0 if at TOS) or -1 if not found Static semantics Perform left to right traversal, and perform different actions depending on subtree and node visited when working in before program, process the identifiers there as in the global option (or process as local if desired using similar mechanism as below) when working in a or the of a func set varCount=0 for this block in of this assume ID token v when varCount>0, call find(v) and error/exit if it returns non-negative number < varCount (means that multiple definition in this block) push(v) and varCount++ when identifier token found in any non-var node (variable use) call find(v), if -1 try STV.verify(v) (if STV used for the global variables) and error if still not found when leaving the block, call pop() varCount times (note that varCount must be specific to each block) Stat Semantics Definition The only static semantics we impose that can be processed by the compiler (static) are proper definition and use of variables. Variable A variable has to be defined before being used for the first time (after satisfying syntax) create Identifier := Integer defines the variable named Identifier. We can assume that it will be initially set to the value in Integer. Identifier showing up in any statement is the variable's use Variable name can only be defined once in a scope but can possibly be reused in another scope. Global option for all variables (max 75) There is only one scope, the global scope, regardless of where a variable is defined. Note that this option in P3 will likely force you to use the easier option in P4 resulting in about 10-15% loss on P4. Local option (max 100) Variables defined before the tape keyword are considered in the global scope, those inside of any block or func are considered scoped in that block. We will use the same scoping rules as in C - a variable is for use in a scope if it is defined in this scope, any of its enclosing scopes, or the global scope (static scoping rules), except for one change. If two variables exist in the same scope, then it is an error. So if you had a global variable called "dog" and a local variable called "dog" this would be a problem. This option here will allow you to use the full option in P4 or the easier one if you so choose. Do not display the tree any more.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please provide code in C language. I need code for staticsemantic.c and staticsemantic.h Please provide code according to local option: You may process all variables using local scope rules, or process variables before program as global and all other variables as local. Software support Implement a stack adapter according to the following Stack item type is String or whatever was your identifier token instance - the stack will process identifiers. You may also store line number or the entire token for more detailed error messaging You can assume no more than 100 items in a program and generate stack overflow if more Interface void push(String); just push the argument on the stack void pop(void); just remove int find(String); the exact interface may change, see below find the first occurrence of the argument on the stack, starting from the top and going down to the bottom of the stack return the distance from the TOS (top of stack) where the item was found (0 if at TOS) or -1 if not found Static semantics Perform left to right traversal, and perform different actions depending on subtree and node visited when working in before program, process the identifiers there as in the global option (or process as local if desired using similar mechanism as below) when working in a or the of a func set varCount=0 for this block in of this assume ID token v when varCount>0, call find(v) and error/exit if it returns non-negative number < varCount (means that multiple definition in this block) push(v) and varCount++ when identifier token found in any non-var node (variable use) call find(v), if -1 try STV.verify(v) (if STV used for the global variables) and error if still not found when leaving the block, call pop() varCount times (note that varCount must be specific to each block) Stat Semantics Definition The only static semantics we impose that can be processed by the compiler (static) are proper definition and use of variables. Variable A variable has to be defined before being used for the first time (after satisfying syntax) create Identifier := Integer defines the variable named Identifier. We can assume that it will be initially set to the value in Integer. Identifier showing up in any statement is the variable's use Variable name can only be defined once in a scope but can possibly be reused in another scope. Global option for all variables (max 75) There is only one scope, the global scope, regardless of where a variable is defined. Note that this option in P3 will likely force you to use the easier option in P4 resulting in about 10-15% loss on P4. Local option (max 100) Variables defined before the tape keyword are considered in the global scope, those inside of any block or func are considered scoped in that block. We will use the same scoping rules as in C - a variable is for use in a scope if it is defined in this scope, any of its enclosing scopes, or the global scope (static scoping rules), except for one change. If two variables exist in the same scope, then it is an error. So if you had a global variable called "dog" and a local variable called "dog" this would be a problem. This option here will allow you to use the full option in P4 or the easier one if you so choose. Do not display the tree any more.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education