digitalmars.D.learn - Are Delimited strings and HereDoc strings just here to suck ?
- Klaus (3/3) Aug 11 2014 I mean when writing a D lexer, you necessarly reach the moment
- H. S. Teoh via Digitalmars-d-learn (15/19) Aug 11 2014 I use heredocs every now and then when I need to embed long strings in
- Klaus (6/34) Aug 11 2014 Yep I think you get what I mean: "clearly over the top",
- Philippe Sigaud via Digitalmars-d-learn (4/12) Aug 11 2014 Out of curiosity, how does a lexer deal with heredocs? It's a sort
- H. S. Teoh via Digitalmars-d-learn (15/30) Aug 11 2014 In Flex, one way you can implement heredocs is to have a separate "mode"
- Philippe Sigaud via Digitalmars-d-learn (3/9) Aug 11 2014 Ah, a small, specialized sub-lexer. OK, I get it.
- Brian Schott (2/5) Aug 11 2014 They are and they do.
- Brian Schott (2/8) Aug 11 2014 Also, use this: https://github.com/Hackerpilot/libdparse
I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"
Aug 11 2014
On Mon, Aug 11, 2014 at 07:47:44PM +0000, Klaus via Digitalmars-d-learn wrote:I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"I use heredocs every now and then when I need to embed long strings in my program. It's one of the things I *like* about D, in fact. Nobody wants to manually parenthesize every quoted line with '"...\n"' when the program need to incorporate several pages of built-in help text, for example. Delimited strings are useful when writing code/text generators when you need to be able to use ' and " as literal characters without crazy leaning-toothpick syndrome \"x\"y\"z\"w\"'s sprinkled everywhere. The crazy variety of ways to write string literals in D, OTOH, *is* a bit over the top, as I found out myself when I also tried writing a D lexer. :-P T -- LINUX = Lousy Interface for Nefarious Unix Xenophobes.
Aug 11 2014
On Monday, 11 August 2014 at 20:10:47 UTC, H. S. Teoh via Digitalmars-d-learn wrote:On Mon, Aug 11, 2014 at 07:47:44PM +0000, Klaus via Digitalmars-d-learn wrote:Yep I think you get what I mean: "clearly over the top", particularly when each element of your arm is 50% over the top and then when you try to show the top with an over-sized arm then it's clearly an "over-toped position".I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"I use heredocs every now and then when I need to embed long strings in my program. It's one of the things I *like* about D, in fact. Nobody wants to manually parenthesize every quoted line with '"...\n"' when the program need to incorporate several pages of built-in help text, for example. Delimited strings are useful when writing code/text generators when you need to be able to use ' and " as literal characters without crazy leaning-toothpick syndrome \"x\"y\"z\"w\"'s sprinkled everywhere. The crazy variety of ways to write string literals in D, OTOH, *is* a bit over the top, as I found out myself when I also tried writing a D lexer. :-P T
Aug 11 2014
On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Mon, Aug 11, 2014 at 07:47:44PM +0000, Klaus via Digitalmars-d-learn wrote:I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"The crazy variety of ways to write string literals in D, OTOH, *is* a bit over the top, as I found out myself when I also tried writing a D lexer. :-POut of curiosity, how does a lexer deal with heredocs? It's a sort of... user-defined token, right?
Aug 11 2014
On Mon, Aug 11, 2014 at 10:50:34PM +0200, Philippe Sigaud via Digitalmars-d-learn wrote:On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:In Flex, one way you can implement heredocs is to have a separate "mode" where the lexer is scanning for the ending string. So basically you have a sub-lexer that treats the heredoc as three tokens, one that defines the ending string for the heredoc (which is never returned to the caller), one that contains the content of the heredoc, and the terminating token (also never returned to the caller). It's not that much different from any other string literal scanning (the lexer must switch into "string literal mode" where things like \n and \t have a different meaning than in the program code proper, and it exits that mode when it encounters the terminating '"'), except that here, the terminating delimiter is variable. T -- Real men don't take backups. They put their source on a public FTP-server and let the world mirror it. -- Linus TorvaldsOn Mon, Aug 11, 2014 at 07:47:44PM +0000, Klaus via Digitalmars-d-learn wrote:I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"The crazy variety of ways to write string literals in D, OTOH, *is* a bit over the top, as I found out myself when I also tried writing a D lexer. :-POut of curiosity, how does a lexer deal with heredocs? It's a sort of... user-defined token, right?
Aug 11 2014
On Mon, Aug 11, 2014 at 10:58 PM, H. S. Teoh via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:In Flex, one way you can implement heredocs is to have a separate "mode" where the lexer is scanning for the ending string. So basically you have a sub-lexer that treats the heredoc as three tokens, one that defines the ending string for the heredoc (which is never returned to the caller), one that contains the content of the heredoc, and the terminating token (also never returned to the caller).Ah, a small, specialized sub-lexer. OK, I get it.
Aug 11 2014
On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote:I mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"They are and they do.
Aug 11 2014
On Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote:On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote:Also, use this: https://github.com/Hackerpilot/libdparseI mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"They are and they do.
Aug 11 2014
On Monday, 11 August 2014 at 22:24:28 UTC, Brian Schott wrote:On Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote:Sorry...I've been stupid...how could I missed that...Sometime I hate myself.On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote:Also, use this: https://github.com/Hackerpilot/libdparseI mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"They are and they do.
Aug 11 2014
On Monday, 11 August 2014 at 22:56:27 UTC, Klaus wrote:On Monday, 11 August 2014 at 22:24:28 UTC, Brian Schott wrote:https://github.com/search?l=D&o=desc&q=stars%3A>%3D0&ref=advsearch&s=updated&type=RepositoriesOn Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote:Sorry...I've been stupid...how could I missed that...Sometime I hate myself.On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote:Also, use this: https://github.com/Hackerpilot/libdparseI mean when writing a D lexer, you necessarly reach the moment when you think: "Oh no! is this feature just here to suck ?"They are and they do.
Aug 11 2014