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

3. 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. E.G. if there is a {, it must be closed with } and same for parenthesis.
More examples:
Valid:
S{ S}
Invalid (In order for the parenthesis/brackets to be closed, there must be a matching open and close parenthesis/brackets.):
S{ S)
More complex examples:
Valid:
Smy_fib_func(int num){ Sif(num<2){ Sreturn num; S} Sreturn fib(n-1)+fib(n-2); S}]

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!