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

Single statement taking minutes to be parsed #1151

Open
gquerret opened this issue Jan 9, 2025 · 5 comments
Open

Single statement taking minutes to be parsed #1151

gquerret opened this issue Jan 9, 2025 · 5 comments
Labels

Comments

@gquerret
Copy link
Contributor

gquerret commented Jan 9, 2025

On behalf of CNAF

Proparse can parse this procedure very quickly:

define variable xx as integer extent 20.
define variable sep as character initial ';'.
put unformatted "header" +
            if xx[1] = ? then "" else string(xx[1]) + sep +
            if xx[1] = ? then "" else string(xx[1]) + sep
   .

With 10 nested if / then / else functions in the put statement, then Proparse takes 500 ms.
With 15 nested functions, Proparse takes 2 seconds.
With 20 nested functions, Proparse takes 50 seconds.

@gquerret
Copy link
Contributor Author

gquerret commented Jan 9, 2025

I'll quickly investigate, but it's unlikely to be fixed. Code is ambiguous, and ANTLR has to find all viable paths before choosing one. In this case, the number of paths grows exponentially with the number of if / then / else functions.

@ccecvb
Copy link

ccecvb commented Jan 10, 2025

out of curiosity would brackets help ?

define variable xx as integer extent 20.
define variable sep as character initial ';'.
put unformatted "header" +
            (if xx[1] = ? then "" else string(xx[1])) + sep +
            (if xx[1] = ? then "" else string(xx[1])) + sep
   .

In that case is it possible to have a rule conditional-expressions-should-be-in-brackets ?

Copy link
Contributor Author

gquerret commented Jan 10, 2025

out of curiosity would brackets help ?

Yes, that removes the ambiguity.

In that case is it possible to have a rule conditional-expressions-should-be-in-brackets ?

Could be done

@ccecvb
Copy link

ccecvb commented Jan 10, 2025

@gquerret conditional-expressions-should-be-in-brackets is actually part of our coding convention. Do you prefer that I create a separate enhancement request for such a rule ?

@gquerret
Copy link
Contributor Author

@ccecvb Yes please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants