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

Tokenisation operator #205

Merged
merged 4 commits into from Dec 30, 2017
Merged

Tokenisation operator #205

merged 4 commits into from Dec 30, 2017

Conversation

VVWVV
Copy link
Contributor

@VVWVV VVWVV commented Oct 27, 2017

#155
Example:

#define foo(%1,%2) %1##%2

main() {
    new barbaz;
    printf("%d", foo(bar, baz));
}

@Zeex
Copy link
Member

Zeex commented Oct 27, 2017

This patch needs to check if the ## is inside a string literal because:

print("##");

^ will print (null).

@Crytrax
Copy link

Crytrax commented Nov 3, 2017

This patch breaks YSI. The following is the compiler's output.

Dependencies\CoreUtils\YSI\Init\..\YSI_Server\..\YSI_Data\..\YSI_Internal\..\YSI_Core\..\YSI_Coding\y_va.inc(112) : error 027: invalid character constant

Can anyone else confirm that this is not just some mistake on my end?

@Dayvison
Copy link

Dayvison commented Nov 3, 2017

This commit 0786aed is breaking

@edit but if i comment this line

ppconcat((char*)lptr);

All works fine :?

@Crytrax
Copy link

Crytrax commented Nov 3, 2017

Commit f59b285 fixes this. Thanks @VVWVV

@Y-Less
Copy link
Member

Y-Less commented Nov 4, 2017

One thing to be aware of, as I've seen this a few times:

#define COLOR_RED #FF0000

SendClientMessage(playerid, COLOR_GREEN, "Hello {"#COLOR_RED"} world");

Not sure what would happen there. But it shouldn't be too hard to avoid by skipping backtracking too much when you do symbol replacements.

@Zeex Zeex merged commit 82dd745 into pawn-lang:master Dec 30, 2017
@Zeex
Copy link
Member

Zeex commented Dec 31, 2017

#224

Zeex added a commit that referenced this pull request Dec 31, 2017
This reverts commit 82dd745, reversing
changes made to 2a930ce.
maddinat0r added a commit to Y-Less/sscanf that referenced this pull request Dec 31, 2017
Zeex' PAWN fork version 3.10.5 introduced a concatenation operator
(pawn-lang/compiler#205), which breaks the extract macro (pawn-lang/compiler#224).
This commit should fix that problem. Also resolves #16.
@Zeex
Copy link
Member

Zeex commented Jan 5, 2018

@VVWVV If you're going to work on this and re-submit, please also include a test that covers as much test cases as you can think of. For example, ## inside macros, outisde of macros, with spaces around and without, insides strings and outside, and so on.

We're starting to add compile and crash tests for new issues (and hopefully runtime tests soon). See source/compiler/tests and source/compiler/tests/CMakeLists.txt for examples.

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

Successfully merging this pull request may close these issues.

None yet

5 participants