Question: 3 . Linter A new programming language called TwoThirtyTwo was just created. An IDE extension is being developed to help programmers quickly see if their
Linter
A new programming language called TwoThirtyTwo was just created. An IDE extension is being developed to help programmers quickly see if their code has any errors without compiling. Your task is to make a linter that determines whether code is valid or not for that extension.
Rules of the language:
Every line needs to start with an S Note that a line may have whitespaces prior to the S on that line.
Every line needs to end with a ; or a
All curly brackets and parenthesis must be opened and closed properly.
Completely empty lines are valid.
Hint: Use counter variables and increase them by one for open parenthesis or curly brackets and decrease it for closed parenthesis or curly brackets.
Examples:
SStart; valid line SStart ; valid line Send invalid line end ; invalid
Note: Parenthesis must also be closed. EG if there is a it must be closed with and same for parenthesis.
More examples:
Valid:
S S
Invalid In order for the parenthesisbrackets to be closed, there must be a matching open and close parenthesisbrackets:
S S
More complex examples:
Valid:
Smyfibfuncint num Sifnum Sreturn num; S Sreturn fibnfibn; S
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
