-
Notifications
You must be signed in to change notification settings - Fork 169
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
Zephir: re2c 1.0.2 keeps the initial "/" at the beginning of an "docblock" #197
Comments
Actually this is temporary workaround to be able try latest changes of re2c >= 1.x. Related issues: * skvadrik/re2c#197 * #31 * zephir-lang/zephir#1591 * phalcon/cphalcon#13140
Hi Serghei, I'm unable to reproduce the difference with re2c-1.0.2 and re2c-0.15.3.
The output is identical (up to the date and version info that re2c includes in the generated file). So please attach the full example and re2c options. |
I managed to reproduce the dfference on |
Did you test with re2c-0.16? It seems that the change is between 0.15.3 and 0.16 rather than between 0.16 and 1.0.2. |
Hmmm.. Nope :-/ I have to try |
Just tested 0.16. Works as expected (without initial "/"). |
Ok, what re2c options are you using? |
|
One of the differences between 0.16 and 1.0.2 is in handling |
Here are two files: |
Both tests was passed successfully. |
Just to you know. Such ugly patch: DCOMMENT = ("/**"([^*]+|[*]+[^/*])*[*]*"*/");
DCOMMENT {
++ if (q[0] == '/') {
++ q++;
++ }
token->opcode = XX_T_COMMENT;
token->value = estrndup(q, YYCURSOR - q - 1);
token->len = YYCURSOR - q - 1;
{
int k, ch = s->active_char;
for (k = 0; k < (token->len - 1); k++) {
if (token->value[k] == '\n') {
ch = 1;
s->active_line++;
} else {
ch++;
}
}
s->active_char = ch;
}
q = YYCURSOR;
return 0;
} solves all our problems. I used this patched version called as "development" in Zephir tests. As you can see all tests with patched parser version was passed successfully: https://travis-ci.org/phalcon/zephir/builds/297509488. Yes, there are failed tests for non patched version. Also I used local environment to tests Zephir Parser with: https://github.com/phalcon/php-zephir-parser/blob/development/install-development -- ${RE2C_BIN} --no-generation-date -o scanner.c scanner.re
++ cp ../parser1.cc.txt scanner.c and -- ${RE2C_BIN} --no-generation-date -o scanner.c scanner.re
++ cp ../parser2.cc.txt scanner.c All tests of Zephir Parser was passed successfully. |
@skvadrik Both files has |
Yes, they were generated with two intermediate re2c versions (between 0.16 and 1.0.2), different in one commit only. Now at least we know that the changes introduced by f51403d do not break anything. I will try building |
Feel free to ask me in case of any issue with setting up local environment. |
Eh, it turns out f51403d is the faulty commit indeed. When I sent you the pre-generated files, I forgot to comment out your fix, so naturally you weren't able to spot the difference. :) |
So after some thinking I've come to the following conclusions. The real problem seems to be in the use of local variable After f51403d re2c does more aggressive dead code elimination. In particular, it probably eliminates some useless writes to The fix would be to introduce a separate local variable for --- a/parser/scanner.re
+++ b/parser/scanner.re
@@ -18,9 +18,9 @@
#define YYCURSOR (s->start)
#define YYLIMIT (s->end)
-#define YYMARKER q
+#define YYMARKER qm
int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
- char *q = YYCURSOR, *start = YYCURSOR;
+ char *q = YYCURSOR, *start = YYCURSOR, *qm;
int status = XX_SCANNER_RETCODE_IMPOSSIBLE;
int is_constant = 0, j; Also, you may find it useful to run re2c with This is an unrelated issue, but in your grammar comments of the form |
Oh, good catch! I'll try to play around with this ASAP. Currently 00:30 AM here :) |
Sure, there's no rush. Now that I know that it's not a bug in re2c internal optimization algorithm, I don't need to fix anything. And you have a workaround for If you have any further troubles with re2c API, I'd be glad to help. I'm leaving the bug open until everything is sorted out. |
sorry for the offtopic, I just can not restrain myself |
Eh, things might have been different if it was a bug in re2c internals. :D |
Fixed. Thank you very much 👍 |
Cool! |
Hi @skvadrik
It seems to me there are some backward incompatible changes in re2c 1.x.
We use the following expression for Zephir Language:
to find comments of the form:
So
token->value
for re2c >= 0.13.6 && < 1.0 is:but for re2c >= 1.0 is:
Did I create the backward incompatible expression to catch "docblocks" or is it the expected behavior?
Thanks
Refs: zephir-lang/php-zephir-parser#31
The text was updated successfully, but these errors were encountered: