Add string literal concatenation using ellipses "..." (bug 4261)#5
Conversation
Backported the changes CompuPhase did to the compiler to support string literal concatenation including all fixes in later commits from r30 on. http://code.google.com/p/pawnscript/source/detail?r=30 Pawn uses ellipses "..." to concatenate so it looks like this: #define PROJECT_AUTHOR "Greyscale" #define PROJECT_COPYRIGHT "Copyright (C) 2010 " ... PROJECT_AUTHOR This would result in PROJECT_COPYRIGHT being defined as "Copyright (C) 2010 Greyscale" While i've been at it, that stringizing a macro parameter feature was ported too. From the changelog for version 3.3.4026 (http://www.compuphase.com/pawn/pawnhistory.htm): The macro substition processor now recognizes the "#" character for "stringizing" a parameter. For example, if you have the definition #define log(%1) #%1 Then the expression log(test) will result in "test". Note that concatenation of literal strings requires an ellipsis in pawn (which is different than C/C++). So to combine the parameter with literal strings, use a syntax like: #define log(%1) "logging: " ... #%1 ... "\n" The stringize operator is only available in the replacement text of a macro. Doing PrintToServer(log(hello)); would print logging: hello\n
sourcepawn/compiler/sc2.c
Outdated
There was a problem hiding this comment.
Can you #if 0 these last four conditions?
|
Moved and added those #if 0 |
commit cd0d318 Author: Peace-Maker <[email protected]> Date: Wed May 28 03:07:25 2014 +0200 Ignore \ ctrlchar in lexing commit cf617a4 Author: Peace-Maker <[email protected]> Date: Tue May 27 13:32:59 2014 +0200 Add string literal concatenation using ellipses "..." (bug 4261) Backported the changes CompuPhase did to the compiler to support string literal concatenation including all fixes in later commits from r30 on. http://code.google.com/p/pawnscript/source/detail?r=30 Pawn uses ellipses "..." to concatenate so it looks like this: #define PROJECT_AUTHOR "Greyscale" #define PROJECT_COPYRIGHT "Copyright (C) 2010 " ... PROJECT_AUTHOR This would result in PROJECT_COPYRIGHT being defined as "Copyright (C) 2010 Greyscale" While i've been at it, that stringizing a macro parameter feature was ported too. From the changelog for version 3.3.4026 (http://www.compuphase.com/pawn/pawnhistory.htm): The macro substition processor now recognizes the "#" character for "stringizing" a parameter. For example, if you have the definition #define log(%1) #%1 Then the expression log(test) will result in "test". Note that concatenation of literal strings requires an ellipsis in pawn (which is different than C/C++). So to combine the parameter with literal strings, use a syntax like: #define log(%1) "logging: " ... #%1 ... "\n" The stringize operator is only available in the replacement text of a macro. Doing PrintToServer(log(hello)); would print logging: hello\n
|
Merged via command-line. |
|
Had to back out since the clang builds failed. https://builds.alliedmods.net/sm/builders/linux-1.6/builds/474/steps/build/logs/stdio Maybe we should have some kind of PR-builder... |
|
Try Travis. |
|
Jenkins could work (and is what I use), but Travis has GitHub support already built-in. Jenkins probably is the better long-term solution though. |
|
Idk how well one could get AMBuilder going with travis. |
|
Hi folks - please keep in mind that, just like Bugzilla, this is our tool for code review. These off-topic discussions make it harder for us to communicate. Please be mindful of what patch authors have to read through to figure out the current state of their PR. |
…lliedmodders#5) commit cd0d318 Author: Peace-Maker <[email protected]> Date: Wed May 28 03:07:25 2014 +0200 Ignore \ ctrlchar in lexing commit cf617a4 Author: Peace-Maker <[email protected]> Date: Tue May 27 13:32:59 2014 +0200 Add string literal concatenation using ellipses "..." (bug 4261) Backported the changes CompuPhase did to the compiler to support string literal concatenation including all fixes in later commits from r30 on. http://code.google.com/p/pawnscript/source/detail?r=30 Pawn uses ellipses "..." to concatenate so it looks like this: #define PROJECT_AUTHOR "Greyscale" #define PROJECT_COPYRIGHT "Copyright (C) 2010 " ... PROJECT_AUTHOR This would result in PROJECT_COPYRIGHT being defined as "Copyright (C) 2010 Greyscale" While i've been at it, that stringizing a macro parameter feature was ported too. From the changelog for version 3.3.4026 (http://www.compuphase.com/pawn/pawnhistory.htm): The macro substition processor now recognizes the "#" character for "stringizing" a parameter. For example, if you have the definition #define log(%1) #%1 Then the expression log(test) will result in "test". Note that concatenation of literal strings requires an ellipsis in pawn (which is different than C/C++). So to combine the parameter with literal strings, use a syntax like: #define log(%1) "logging: " ... #%1 ... "\n" The stringize operator is only available in the replacement text of a macro. Doing PrintToServer(log(hello)); would print logging: hello\n
…61, PR alliedmodders#5)" This reverts commit 7868767.
Add string literal concatenation using ellipses "..." (bug 4261, PR #5, r=dvander).
Don't drop objects without comments
RAWMODE was the ability to prefix a string such that escape characters would be inserted literally, similar to the "r" prefix in Python. It used sc_ctrlchar as the prefix. For reasons unknown, I requested this feature be disabled when literal concatenation support was backported [1]. Since then, it was further broken when the lexer was rewritten and simplified. It hasn't worked in 6 years, and no one has been clamoring for it, so let's just remove all the offending code. If we want to add this back and properly support it, it will not be difficult. [1] alliedmodders/sourcemod#5
RAWMODE was the ability to prefix a string such that escape characters would be inserted literally, similar to the "r" prefix in Python. It used sc_ctrlchar as the prefix. For reasons unknown, I requested this feature be disabled when literal concatenation support was backported [1]. Since then, it was further broken when the lexer was rewritten and simplified. It hasn't worked in 6 years, and no one has been clamoring for it, so let's just remove all the offending code. If we want to add this back and properly support it, it will not be difficult. [1] alliedmodders/sourcemod#5
Backported the changes CompuPhase did to the compiler to support string
literal concatenation including all fixes in later commits from r30 on.
http://code.google.com/p/pawnscript/source/detail?r=30
Pawn uses ellipses "..." to concatenate so it looks like this:
This would result in PROJECT_COPYRIGHT being defined as
"Copyright (C) 2010 Greyscale"
While i've been at it, that stringizing a macro parameter feature was
ported too.
From the changelog for version 3.3.4026
(http://www.compuphase.com/pawn/pawnhistory.htm):
The macro substition processor now recognizes the "#" character for
"stringizing" a parameter. For example, if you have the definition
Then the expression log(test) will result in "test".
Note that concatenation of literal strings requires an ellipsis in pawn
(which is different than C/C++). So to combine the parameter with
literal strings, use a syntax like:
The stringize operator is only available in the replacement text of a
macro.
Doing
would print
logging: hello\n
Corresponding bug: https://bugs.alliedmods.net/show_bug.cgi?id=4261