-
Notifications
You must be signed in to change notification settings - Fork 115
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
fix: improve funcId
recognition and squash misdetection bugs
#636
Conversation
That took a looooooooot of RegEx iterations, including going into `grammar.ts` and trying to adjust things in the semantic analysis. Fortunately, that wasn't needed.
To be on the safe side, let's take |
Co-authored-by: Anton Trunov <[email protected]>
Came up with a simple solution for 0x0_ stuff, so our parser can deal with them too!
Co-authored-by: Anton Trunov <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR accepts, for instance, +
as a valid FunC identifier, but it's actually not.
Something like this should work:
funcInvalidId = "_" ")" --notUnderscore
| ("+" | "-" | "*" | "/" | "~/" | "^/" | "%" | "~%" | "^%" | "/%") ")" --notArithOperator
// more operators here
| ("-"? digit+) ")" --notDecimalNumber
| ("-"? "0x" hexDigit+) ")" --notHexadecimalNumber
funcPlainId = ~funcInvalidId (~(whiteSpace | "(" | ")" | "," | "." | ";" | "~") any)+
Nice observation! I'd try putting lookaheads The keywords are not allowed and should be excluded too. Basically, contents of https://github.com/ton-blockchain/ton/blob/master/crypto/func/keywords.cpp has to be put in the exceptions list. I'm on it. UPD2: Order of operators in those inner () alternations really does matter, the ones with bigger prefix shall stand in front of others. |
There was a suggestion, which didn't pass negative tests, so I hid it.The thing we've engineered works, but possibly I've found a cleaner solution, which doesn't require the ")" and can be used in the FunC parser too (the current approach in this PR fails there in absence of ")" and stuff). But this one works: It passes similar set of tests we have for function identifiers, but adapted to FunC code: UPD: Negative tests failed terribly, reverting :) |
@novusnota So, what's the current status of this PR? |
@anton-trunov It's a working and robust solution. The alternative would be to do invalidation of identifiers during syntactic analysis, which enhances the error messages further, but that seems to be a bit out of scope of this PR. Wdyt? |
That took a looooooooot of RegEx iterations.
Closes #635
- [ ] I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER