Question: Write in C programming Pseudocode for main: Get a string from user If string has correctly matched delimiters print All matched correctly Pseudocode for FSM

Write in C programming
Pseudocode for main:
Get a string from user
If string has correctly matched delimiters print All matched correctly
Pseudocode for FSM to Determine if Delimiters Match:
Note: This is to be implemented as a subprogram that returns a boolean value of true or false indicating whether or not all
delimiters matched correctly.
State 0(Starting State):
Read next character in input string
If char is open delimiter, next state is 1
If char is close delimiter, next state is 2
If char is end of string, next state is 3
If character is anything else, next state is 4
State 1:
Push open delimiter on stack
Next state is 0
State 2:
If stack is not empty
o If the character on top of stack is brother to current character
Next state is 0
o Otherwise
Display error message
Return false
Otherwise
o Display error message
o Return false
Next state is 0
State 3:
If stack is empty
o Return true
Otherwise
o Display error message
o Return false
State 4:
Next state is 0
Note: You are to write and make use of subprograms like is_open, is_close, and is_brother for this program
0. Starting State:
Increment input string's index value
If is operator, next state is 1
If is digit, next state is 2
If is space, next state is 4
If is end of string, next state is 5
If anything else, next state is 6
1. Found operator:
Pop 2nd number off stack
Pop 1st number off stack
Perform operation
Push result on stack
Next state is 0
Note: Watch popping empty stack and division by zero
2. Found digit:
Copy digit to temporary string
increment both the temporary and input string index values
If character in input string is a digit or decimal point
next state is 2
otherwise
next state 3
3. Found end of number:
append \0 on temporary array
convert and assign to variable
push number on stack
reset temp index to 0
decrease input index by 1
next state is 0
4. Found space:
next state is 0
5. Found end of input string:
pop result
return answer
Note: Watch for leftovers on stack
6. Found garbage
display error message
exit from program
1TFVEPDPEFGPS'4.UP&WBMVBUF31/*OQVU
State 0:
Increment index string index
If current input is number, next state is 1
If current input is operator, next state is 2
If current input is left parenthesis, next state is 3
If current input is right parenthesis, next state is 4
If current input is end of string, next state is 5
If current input is garbage, next state is 6
State 1: (found number)
Copy current character to output string
Increment output string index
Increment input string index
While character in input string is digit or decimal point
o Copy character to output string
o Increment output string index
o Increment input string index
Put space in output string
Increment output string index
Decrement input string index
Next state is 0
State 2: (found operator)
While the stack is not empty and the character at top of stack is an operator and the precedence
of the operator that is current character in input string is less than or equal to that of the
operator on top of the stack
o Pop operator off top of stack and put in output string
o Increment output string index
o Put space in output string
o Increment output string index
If stack is not full, Push the operator that is current character in input string on stack
Otherwise, print error and exit
Next state is 0
State 3: (found left parenthesis)
If stack is not full, push left parenthesis found in current input character on stack
Otherwise, display error message and exit
Next state is 0
State 4: (found right parenthesis)
While stack is not empty and item at top of stack is not left parenthesis
o Pop operator off top of stack and put in output string
Pseudocode for FSM Implementing Reduced Version of Dijkstra\Zeta s Shunting Yard Algorithm to Convert Algebraic Input to RPN
o Increment output string index
o Put space in output string
o Increment output string index
If stack is not empty, pop left parenthesis off stop of stack but do not put in output string
Otherwise, display error message (mismatched parenthesis) and exit
Next state is 0
State 5: (End of input)
While stack is not empty and character at top of stack is an operator
o Pop operator off stack and put in output string
o Increment output string index
o Put space in output string
o Increment output string index
If stack is not empty, display error message (leftover parenthesis) and exit
Otherwise, put end of string marker in output string and send output string to RPN Evaluator
Note: return rpneval(output_string);
State 6: (garbage)
Display error message and exit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!