DIP 1026---Deprecate Context-Sensitive String Literals---Community Review Round 1
Kagamin
spam at here.lot
Wed Dec 4 19:13:11 UTC 2019
On Tuesday, 3 December 2019 at 12:38:29 UTC, Andrei Alexandrescu
wrote:
> This DIP is a non-starter. Here documents are easily and
> effectively handled during lexing and have no impact on the
> language grammar.
In a compiler.
Here's an implementation for bash heredoc strings, say something
nice about it:
---
class HereDocCls { // Class to manage HERE document elements
public:
int State; // 0: '<<' encountered
// 1: collect the delimiter
// 2: here doc text (lines after the delimiter)
int Quote; // the char after '<<'
bool Quoted; // true if Quote in ('\'','"','`')
bool Indent; // indented delimiter (for <<-)
int DelimiterLength; // strlen(Delimiter)
char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf
HereDocCls() {
State = 0;
Quote = 0;
Quoted = false;
Indent = 0;
DelimiterLength = 0;
Delimiter = new char[HERE_DELIM_MAX];
Delimiter[0] = '\0';
}
void Append(int ch) {
Delimiter[DelimiterLength++] = static_cast<char>(ch);
Delimiter[DelimiterLength] = '\0';
}
~HereDocCls() {
delete []Delimiter;
}
};
HereDocCls HereDoc;
---
More information about the Digitalmars-d
mailing list