Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 1.24 KB

File metadata and controls

17 lines (15 loc) · 1.24 KB

Algorithm

  • Step 1: Start.
  • Step 2: Initialize an index i to track the current character in the input string.
  • Step 3: Call the function E() to begin parsing from the start symbol.
  • Step 4: Inside E(), call T() to process the T non-terminal.
  • Step 5: In T(), call F() to process the F non-terminal.
    • Step 5.1: If the current character is '(', call E() recursively and expect a closing ')'.
    • Step 5.2: Else, if the current character is an identifier (alphabetic), accept it and move to the next character.
    • Step 5.3: If neither condition is met, reject the string.
  • Step 6: After processing F(), call TP() to check for any further * operator followed by another F(). Repeat this step recursively if needed. If no * is found, accept the empty production (@).
  • Step 7: After processing T(), call EP() to check for any further + operator followed by another T(). Repeat this step recursively if needed. If no + is found, accept the empty production (@).
  • Step 8: After E() finishes, check if the entire input has been consumed (i.e., input[i] == '\0').
    • Step 8.1: If yes, accept the string.
    • Step 8.2: If not, reject the string.
  • Step 9: Stop.