Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An extra brace (curly bracket) or parenthesis at the top level , will terminate umple code processing #2023

Closed
TimLethbridge opened this issue Feb 16, 2023 · 7 comments
Assignees
Labels
bug Crashes or wrong results Component-SyntaxAndParsing Related to the Umple grammar and the parser that builds the abstract syntax tree and analyses models Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users

Comments

@TimLethbridge
Copy link
Member

In the following example

class X {}}
  thisIsIgnored;
}

class WholeClassIsIgnored {
}

... the extra closing brace will terminate all subsequent processing of input. That means that if anyone accidentally has one more closing brace than opening one at any point in their code, then code will be ignored and this may be very hard to debug.

Somehow the parser should detect the extra closing brace and raise an error message at that point.

@TimLethbridge TimLethbridge added bug Crashes or wrong results Priority-High This problem or enhancement is likely to be highly visible and or impactful of users Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Component-SyntaxAndParsing Related to the Umple grammar and the parser that builds the abstract syntax tree and analyses models labels Feb 16, 2023
@TimLethbridge
Copy link
Member Author

An extra opening brace has the same effect.

Adding a grammar rule (and processing in UmpleInternalParser_CodeClass.ump) to catch an loose braces and raise new error messages (e.g. 1504) at the top level seemed to have no effect, yet broke certain code in the RealTimeCPP generator.

Perhaps the answer would be to determine if there are characters not processed beyond the end of parsing, and if so raise an error message.

@TimLethbridge TimLethbridge changed the title An extra closing brace (curly bracket) not matched by an open one, will terminate umple code processing An extra brace (curly bracket) or parenthesis at the top level , will terminate umple code processing Sep 27, 2023
@TimLethbridge
Copy link
Member Author

we discovered that any { or } or {} ot () or ( or ) will terminate processing

I suggest trying to match these using a regex in line 14 of umple_core.grammar and then detecting that in class/UmpleInternalParser_CodeClass.ump and calling setFailedPosition with a new warning in en.error

We already added the message to branch issue2023curlybracket so use that branch

@TimLethbridge
Copy link
Member Author

I give a 60% chance that we could follow the following approach.

  1. Modify the grammar rule umpleProgram. Change it so that at the top level, in addition to a comment or a directive or a semicolon (any of which can be interleaved), a new [invalidBracket:{|}|(|)] could be present. This might need to instead be specified using a regular expression [!invalidBracket:XXXX] where XXXXX would be the regex.

  2. Then in the umpleInternalParser code we would detect the presence of an invalidBracket, issue a warning and ignore it.

  3. We would want to add test to demonstrate that the warning is detected.

If that doesn't work, we may have to dig deeper.

@TimLethbridge
Copy link
Member Author

New suggestion: Look for malformedStatement processing in the umple_exceptions.grammar. Consider the extra brackets as a new type of maformed statement. Create a regex to match, and then process the resulting rule (which would be near class/UmpleInternalParser_CodeClass.ump:5640: ... note that all you need to do is to output a warning)

@AxelTWC AxelTWC self-assigned this Oct 24, 2023
@AxelTWC
Copy link
Contributor

AxelTWC commented Nov 1, 2023

Created PR which detects open and close (round and curly brackets). Next step is to create test cases and write the user manual for the warning.

TimLethbridge added a commit that referenced this issue Nov 14, 2023
Issue2023curlybracket ... first phase of resolution of issue #2023. The tests have to be added in the next iteration as well as potentially clean up regarding #2056
@AxelTWC
Copy link
Contributor

AxelTWC commented Nov 14, 2023

The new PR merged has the following information:

PR #2049

This code currently raises a warning and detects the following Extra Brackets:

  • OPEN_ROUND_BRACKETS
  • CLOSE_ROUND_BRACKETS
  • OPEN_CURLY_BRACKETS
  • CLOSE_CURLY_BRACKETS
    and outputs the warning number 1016.

In order to remove the warning, the user would need to look at the warning message showing the line number of the extra bracket.

Note

For Developers, Quick Build the Compiler twice as there is an edit in the Umple Internal Parser Code.
Multiple Test Cases has been added to test and solve this issue.
An extra user manual guideline has been added to show how to reproduce this warning and how to solve the warning.

@TimLethbridge
Copy link
Member Author

Fixed by #2057 and #2049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Crashes or wrong results Component-SyntaxAndParsing Related to the Umple grammar and the parser that builds the abstract syntax tree and analyses models Diffic-Med A non-trivial problem that may take over a week or may not be obvious how to fix or require analysis Priority-High This problem or enhancement is likely to be highly visible and or impactful of users
Projects
None yet
Development

No branches or pull requests

2 participants