Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 1.09 KB

File metadata and controls

18 lines (15 loc) · 1.09 KB

Algorithm

  • Step 1: Start

  • Step 2: Read a character from the input file

  • Step 3: If it is an Operator goto step 4 else goto step 7

  • Step 4: Check if it is '/' and the next character is '/' or '*' If yes goto step 5 else goto step 6

  • Step 5: Ignore all the character using a while loop until the characters '//' or '*/' is encountered respectively and in order.

  • Step 6: Print the character as an operator

  • Step 7: Check if it is a Special character if yes print it as special character

  • Step 8: Check if it is a digit if yes print it as a digit

  • Step 9: Check if it is an alphabet if true goto step 10 else goto step 12

  • Step 10: Read the character following using a while loop into a temporary array until a delimiter is encountered ( space )

  • Step 11:Check if the string read is a valid keyword If true print it as a keyword else as an Identifier.

  • Step 12: Increment the variable tracking the current line number.

  • Step 13: Do step 2 to step 12 until the end of file is encountered.

  • Step 14: Stop