Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 00:44:58 UTC, jmh530 wrote: On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote: [snip] Yes. std.random is another. I gave up out on the current one. Luckily I already had external libraries for that before I started using D. Have you tried mir.rand

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote: [snip] Yes. std.random is another. I gave up out on the current one. Luckily I already had external libraries for that before I started using D. Have you tried mir.random?

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 22:58:17 UTC, Ali Çehreli wrote: On 2/21/22 09:34, bachmeier wrote: > I may have to look for an alternative > JSON library for D. std.json is not the most fun independent of this issue. std.json is a very good module. At work, we had to write additional code to c

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread Ali Çehreli via Digitalmars-d-learn
On 2/21/22 14:58, Ali Çehreli wrote: > std.json is a very good module. Correction: std.json is NOT a very good module. Ali

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bauss via Digitalmars-d-learn
On Monday, 21 February 2022 at 15:13:52 UTC, Kagamin wrote: On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote: Why are we even escaping them by default, it should be the other way around, that slashes are only escaped if you ask for it; that's how it literally is in almost every JSON lib

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread Ali Çehreli via Digitalmars-d-learn
On 2/21/22 09:34, bachmeier wrote: > I may have to look for an alternative > JSON library for D. std.json is not the most fun independent of this issue. std.json is a very good module. At work, we had to write additional code to cover its defficiencies. Looking forward to versioning in Phob

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 17:50:56 UTC, bachmeier wrote: I looked at the source for `parseJSON` and I see references only to `JSONOptions.strictParsing` and `JSONOptions.specialFloatLiterals`. I may be missing something, but I don't see any option to iterating over every element and unes

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
ot;: "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of the forward slash? Is there some reason I should want to escape the forward slash? The options are applied on parsing

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote: Why are we even escaping them by default, it should be the other way around, that slashes are only escaped if you ask for it; that's how it literally is in almost every JSON library. Escaping slashes as a default is a huge mistake IMHO

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bachmeier via Digitalmars-d-learn
s)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of the forward slash? Is there some reason I should want to escape the forward slash? The options are applied on parsing or output but do not stay with the item! So just because

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread Kagamin via Digitalmars-d-learn
On Monday, 21 February 2022 at 09:04:06 UTC, bauss wrote: Why are we even escaping them by default, it should be the other way around, that slashes are only escaped if you ask for it; that's how it literally is in almost every JSON library. Really? I always see escaped slashes in JSON, e.g. wi

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread bauss via Digitalmars-d-learn
On Monday, 21 February 2022 at 03:42:55 UTC, bachmeier wrote: I tried this ``` import std.json, std.stdio; void main() { writeln(parseJSON(`{"a": "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
`` Is there a way to avoid the escaping of the forward slash? Is there some reason I should want to escape the forward slash? The options are applied on parsing or output but do not stay with the item! So just because you parsed without allowing escapes on slashes doesn't mean the output

Is there a way to not escape slashes when parsing JSON?

2022-02-20 Thread bachmeier via Digitalmars-d-learn
I tried this ``` import std.json, std.stdio; void main() { writeln(parseJSON(`{"a": "path/file"}`, JSONOptions.doNotEscapeSlashes)); } ``` but the output is ``` {"a":"path\/file"} ``` Is there a way to avoid the escaping of the forward slash? Is there some reason I should want to escap

Re: Recommendations on parsing XML via an InputRange

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
hat's unfortunate, because my next enhancement was to start parsing streams as they come in from stdin. (doh!) So I've learned my lesson and will RTFM closer next time, but now I'm casting about for a solution.  Two ideas, either: 1. Find a different StAX-ish parser that works wi

Recommendations on parsing XML via an InputRange

2021-09-13 Thread Chris Piker via Digitalmars-d-learn
nhancement was to start parsing streams as they come in from stdin. (doh!) So I've learned my lesson and will RTFM closer next time, but now I'm casting about for a solution. Two ideas, either: 1. Find a different StAX-ish parser that works with `InputRange` (and buffers internally

Re: Swedish letters fuck up parsing into SQL querry

2020-03-24 Thread Anders S via Digitalmars-d-learn
On Tuesday, 24 March 2020 at 14:10:19 UTC, WebFreak001 wrote: On Tuesday, 24 March 2020 at 11:15:24 UTC, matheus wrote: On Monday, 23 March 2020 at 15:41:50 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 15:15:12 UTC, Anders S wrote: I'm creating a connection to the db and conn.exec(sql

Re: Swedish letters fuck up parsing into SQL querry

2020-03-24 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 24 March 2020 at 11:15:24 UTC, matheus wrote: On Monday, 23 March 2020 at 15:41:50 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 15:15:12 UTC, Anders S wrote: I'm creating a connection to the db and conn.exec(sql) It depends on the library but it is almost always easier to

Re: Swedish letters fuck up parsing into SQL querry

2020-03-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/24/20 7:15 AM, matheus wrote: On Monday, 23 March 2020 at 15:41:50 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 15:15:12 UTC, Anders S wrote: I'm creating a connection to the db and conn.exec(sql) It depends on the library but it is almost always easier to do it right than to d

Re: Swedish letters fuck up parsing into SQL querry

2020-03-24 Thread matheus via Digitalmars-d-learn
On Monday, 23 March 2020 at 15:41:50 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 15:15:12 UTC, Anders S wrote: I'm creating a connection to the db and conn.exec(sql) It depends on the library but it is almost always easier to do it right than to do it the way you are. like with my

Re: Swedish letters fuck up parsing into SQL querry

2020-03-24 Thread WebFreak001 via Digitalmars-d-learn
On Monday, 23 March 2020 at 15:15:12 UTC, Anders S wrote: On Monday, 23 March 2020 at 15:07:31 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: do you mean I should loop through each pos till strlen(cellTab[CellIndex].name) to find "\0"? strlen is ok, that g

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Anders S via Digitalmars-d-learn
On Monday, 23 March 2020 at 15:07:31 UTC, Adam D. Ruppe wrote: On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: do you mean I should loop through each pos till strlen(cellTab[CellIndex].name) to find "\0"? strlen is ok, that gives the answer itself. Just slice to that. cellTab[CellIn

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Anders S via Digitalmars-d-learn
On Monday, 23 March 2020 at 14:58:03 UTC, bauss wrote: On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: On Monday, 23 March 2020 at 13:53:50 UTC, Adam D. Ruppe wrote: My first thought is to!string(cellTab[CellIndex].name) is wrong, if it is a char[20] you should be scanning it to find

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: do you mean I should loop through each pos till strlen(cellTab[CellIndex].name) to find "\0"? strlen is ok, that gives the answer itself. Just slice to that. cellTab[CellIndex].name[0 .. strlen(cellTab[CellIndex].name.ptr)] could do it

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread bauss via Digitalmars-d-learn
On Monday, 23 March 2020 at 14:26:46 UTC, Anders S wrote: On Monday, 23 March 2020 at 13:53:50 UTC, Adam D. Ruppe wrote: My first thought is to!string(cellTab[CellIndex].name) is wrong, if it is a char[20] you should be scanning it to find the length and slicing. Maybe [0 .. name.indexOf("\0")]

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Anders S via Digitalmars-d-learn
On Monday, 23 March 2020 at 13:53:50 UTC, Adam D. Ruppe wrote: My first thought is to!string(cellTab[CellIndex].name) is wrong, if it is a char[20] you should be scanning it to find the length and slicing. Maybe [0 .. name.indexOf("\0")] or whatever. You also shouldn't be building a query by

Re: Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Adam D. Ruppe via Digitalmars-d-learn
My first thought is to!string(cellTab[CellIndex].name) is wrong, if it is a char[20] you should be scanning it to find the length and slicing. Maybe [0 .. name.indexOf("\0")] or whatever. You also shouldn't be building a query by concatenation.

Swedish letters fuck up parsing into SQL querry

2020-03-23 Thread Anders S via Digitalmars-d-learn
Hi guys, I'm trying to read a name from a struct iorequest where the name is char name[20] The struct is received through a FIFO pipe and message is going into a mysql database to update specific post there. Now my problem is that all works fine to read and stop with '\0' termination till I

Re: Parsing with dxml

2019-11-20 Thread Joel via Digitalmars-d-learn
On Wednesday, 20 November 2019 at 00:07:53 UTC, Joel wrote: On Tuesday, 19 November 2019 at 14:20:39 UTC, Kagamin wrote: On Monday, 18 November 2019 at 06:44:43 UTC, Joel wrote: ``` http://www.w3.org/2001/XMLSchema-instance";> ``` You're missing a closing tag. I can store the ASV Bibl

Re: Parsing with dxml

2019-11-19 Thread Joel via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 14:20:39 UTC, Kagamin wrote: On Monday, 18 November 2019 at 06:44:43 UTC, Joel wrote: ``` http://www.w3.org/2001/XMLSchema-instance";> ``` You're missing a closing tag. I can store the ASV Bible in an array (I check for if the last book, chapter, and ve

Re: Parsing with dxml

2019-11-19 Thread Kagamin via Digitalmars-d-learn
On Monday, 18 November 2019 at 06:44:43 UTC, Joel wrote: ``` http://www.w3.org/2001/XMLSchema-instance";> ``` You're missing a closing tag.

Re: Parsing with dxml

2019-11-18 Thread Joel via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 04:43:31 UTC, Joel wrote: On Tuesday, 19 November 2019 at 02:45:29 UTC, Jonathan M Davis wrote: [...] Thanks for taking the time to reply. I have had another xml Bible version text in the past [1]. It had a different format. And Adam Ruppe helped me by writing

Re: Parsing with dxml

2019-11-18 Thread Joel via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 02:45:29 UTC, Jonathan M Davis wrote: On Sunday, November 17, 2019 11:44:43 PM MST Joel via Digitalmars-d-learn wrote: [...] You need to be checking the type of the entity before you call either name or text on it, because not all entities have a name, and not

Re: Parsing with dxml

2019-11-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 17, 2019 11:44:43 PM MST Joel via Digitalmars-d-learn wrote: > I can only parse one row successfully. I tried increasing the > popFronts, till it said I'd gone off the end. > > Running ./app > core.exception.AssertError@../../../../.dub/packages/dxml-0.4.1/dxml/sourc > e/dxml/p

Re: Parsing with dxml

2019-11-18 Thread Joel via Digitalmars-d-learn
On Monday, 18 November 2019 at 06:44:43 UTC, Joel wrote: with(ver) vers ~= Verse(id,b,c,v,t); Or, vers ~= ver;

Parsing with dxml

2019-11-17 Thread Joel via Digitalmars-d-learn
I can only parse one row successfully. I tried increasing the popFronts, till it said I'd gone off the end. Running ./app core.exception.AssertError@../../../../.dub/packages/dxml-0.4.1/dxml/source/dxml/parser.d(1457): text cannot be called with elementEnd ??:? _d_assert_msg [0

Re: Why Dlang use parsing expression grammar (PEG) parser not BNF?

2019-11-01 Thread user4567 via Digitalmars-d-learn
On Thursday, 31 October 2019 at 08:40:42 UTC, lili wrote: Hi: I want implementation Lua on D, I find that a PEG parser https://github.com/PhilippeSigaud/Pegged why do not use BNF parser. Is PEG better than BNF? IIRC the PEG for D is not complete. You have an EBNF here https://libdparse

Re: Why Dlang use parsing expression grammar (PEG) parser not BNF?

2019-11-01 Thread Dennis via Digitalmars-d-learn
/lang/peg Which says in the abstract: The power of generative grammars to express ambiguity is crucial to their original purpose of modelling natural languages, but this very power makes it unnecessarily difficult both to express and to parse machine-oriented languages using CFGs. Parsing

Why Dlang use parsing expression grammar (PEG) parser not BNF?

2019-10-31 Thread lili via Digitalmars-d-learn
Hi: I want implementation Lua on D, I find that a PEG parser https://github.com/PhilippeSigaud/Pegged why do not use BNF parser. Is PEG better than BNF?

Stream-based on-the-fly-download-and-decompress parsing of files

2019-10-30 Thread Per Nordlöw via Digitalmars-d-learn
Has anybody put together a File-compatible web-download API? Mu goal is to do have it do 1. stream-based download (via http or https), 2. compress (with gzip or bzip2) and 3. textual parse of resources available either on the web or locally cached. An extra bonus would be if the API provided a

Re: How would I know if AppVayer is parsing my yaml file?

2019-07-17 Thread Mike Brockus via Digitalmars-d-learn
my Meson projects and I was wondering how would I know if AppVayer is parsing my yaml file? I know I got a failed build because it was set to MSBuild by default. But after I set the value to script, how would I know it's doing its work and not just spinning its wheels. https://githu

Re: How would I know if AppVayer is parsing my yaml file?

2019-07-17 Thread Paul Backus via Digitalmars-d-learn
AppVayer is parsing my yaml file? I know I got a failed build because it was set to MSBuild by default. But after I set the value to script, how would I know it's doing its work and not just spinning its wheels. https://github.com/squidfarts/d-example.git This is a question about AppVeyor,

How would I know if AppVayer is parsing my yaml file?

2019-07-17 Thread Mike Brockus via Digitalmars-d-learn
If you never seen Meson before then pick up a camera and take a picture: 🤔 👉 https://mesonbuild.com/ Quick question. I started integrating ci/cd best practices to my Meson projects and I was wondering how would I know if AppVayer is parsing my yaml file? I know I got a failed build because

Re: How would I know if appvayer is parsing my yaml file?

2019-07-16 Thread Mike Brockus via Digitalmars-d-learn
On Tuesday, 16 July 2019 at 22:24:32 UTC, Mike Brockus wrote: If you never seen Meson before then set down and take a look: 🤔 👉 https://mesonbuild.com/ Quick question. I started integrating ci/cd best practices to my Meson projects and I was wondering how would I know if AppVayer is parsing

How would I know if appvayer is parsing my yaml file?

2019-07-16 Thread Mike Brockus via Digitalmars-d-learn
If you never seen Meson before then set down and take a look: 🤔 👉 https://mesonbuild.com/ Quick question. I started integrating ci/cd best practices to my Meson projects and I was wondering how would I know if AppVayer is parsing my yaml file? I know I got a failed build because it was set

Re: Parsing URL, Extracting Authority from the URL string

2019-05-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 May 2019 at 14:57:57 UTC, Adam D. Ruppe wrote: idk about phobos, but I have one of these in my web server library git hub link https://github.com/adamdruppe/arsd or dub link http://code.dlang.org/packages/arsd-official

Re: Parsing URL, Extracting Authority from the URL string

2019-05-20 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 20 May 2019 at 14:44:50 UTC, Boqsc wrote: I'm questioning, if D lang will ever include simple URL parsing into their std Phobos library? idk about phobos, but I have one of these in my web server library http://dpldocs.info/experimental-docs/arsd.cgi.Uri.html (also copy/past

Re: Parsing URL, Extracting Authority from the URL string

2019-05-20 Thread Andre Pany via Digitalmars-d-learn
void main() { string url = "https://github.com/BoQsc/notes/archive/master.zip";; // Output: url path: writeln("url path: ", url.rootName); } I'm questioning, if D lang will ever include simple URL parsing into their std Phobos library? Curl added an api to access the

Parsing URL, Extracting Authority from the URL string

2019-05-20 Thread Boqsc via Digitalmars-d-learn
c/notes/archive/master.zip";; // Output: url path: writeln("url path: ", url.rootName); } I'm questioning, if D lang will ever include simple URL parsing into their std Phobos library?

[Pegged] making parsing error informative

2018-11-25 Thread drug via Digitalmars-d-learn
I have the following grammar https://run.dlang.io/is/gRTGm3 If user types `ubyte1` instead of `ubyte` the whole string parsing fails and error message says string is wrong from the start. How can I get more informative message like "unknown type ubyte1" or at least error position

Re: OT: Parsing object files for fun and profit

2018-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 31 May 2018 at 18:33:37 UTC, Ali Çehreli wrote: On 05/31/2018 09:49 AM, Adam D. Ruppe wrote: > Should be fairly simple to follow, just realize that the image is a 2d > block for each char and that's why there's all those multiplies and > divides. I remember doing similar things wit

OT: Parsing object files for fun and profit

2018-05-31 Thread Ali Çehreli via Digitalmars-d-learn
On 05/31/2018 09:49 AM, Adam D. Ruppe wrote: > Should be fairly simple to follow, just realize that the image is a 2d > block for each char and that's why there's all those multiplies and > divides. I remember doing similar things with fonts to add Turkish characters to Digital Research and Wor

Re: dxml behavior after exception: continue parsing

2018-05-09 Thread Jonathan M Davis via Digitalmars-d-learn
he moment for dealing with invalid XML (especially with the issues caused by the fact that only one range actually does the validation, making selective skipping of invalid stuff while parsing a very iffy proposition). dxml was designed with the idea that it would be operating on valid XML, and designing a

Re: dxml behavior after exception: continue parsing

2018-05-08 Thread Jesse Phillips via Digitalmars-d-learn
On Monday, 7 May 2018 at 22:24:25 UTC, Jonathan M Davis wrote: I've been considering adding more configuration options where you say something like you don't care if any invalid characters are encountered, in which case, you could cleanly parse past something like an unescaped &, but you'd the

Re: dxml behavior after exception: continue parsing

2018-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
> } catch (Exception e) { > > > > range.popFront; > > > > } > > Ok so this worked when inside a quoted attribute value but not a > normal tag body. Clearly I'm not parsing valid XML so I'm going > outside the bounds of valid paramet

Re: dxml behavior after exception: continue parsing

2018-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
states: "If invalid XML is encountered at any point during the parsing process, an XMLParsingException will be thrown. If an exception has been thrown, then the parser is in an invalid state, and it is an error to call any functions on it." What happens if you continue parsing after an ex

Re: dxml behavior after exception: continue parsing

2018-05-07 Thread Jesse Phillips via Digitalmars-d-learn
hout issue. Is this something expected and will be maintained? try { range.popFront(); } catch (Exception e) { range.popFront; } Ok so this worked when inside a quoted attribute value but not a normal tag body. Clearly I'm not parsing valid XML so I'm goin

dxml behavior after exception: continue parsing

2018-05-07 Thread Jesse Phillips via Digitalmars-d-learn
So I have an XML like document which fails to adhere completely to XML. One of these such events is that & is used without escaping. My observation is that after the exception it is possible to move to the next element without issue. Is this something expected and will be maintained? t

Re: Command Line Parsing

2018-01-26 Thread ChrisPiker via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 10:58:07 UTC, Nicholas Wilson wrote: On Wednesday, 12 April 2017 at 09:51:34 UTC, Russel Winder wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or

Re: Parsing string to octal(for umask) at runtime?

2017-12-22 Thread Ryan David Sheasby via Digitalmars-d-learn
On Friday, 22 December 2017 at 21:36:20 UTC, Ryan David Sheasby wrote: Hi. Struggling to figure this out. At the bottom of this page: https://dlang.org/library/std/conv/octal.html is a vague reference to using parse. However, when I use what I would assume to be correct based on this: https://

Parsing string to octal(for umask) at runtime?

2017-12-22 Thread Ryan David Sheasby via Digitalmars-d-learn
Hi. Struggling to figure this out. At the bottom of this page: https://dlang.org/library/std/conv/octal.html is a vague reference to using parse. However, when I use what I would assume to be correct based on this: https://dlang.org/phobos/std_conv.html#.parse.3 and the fact that in the octal

Re: Parsing a string from stdin using formattedRead

2017-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 18:47:03 UTC, Mark wrote: formattedRead(readln(), "%s %s", first_name, last_name); You could write a little wrapper function to do that uint myformattedRead (R, Char, S...)(R r, const(Char)[] fmt, auto ref S args) { formattedRead(r, fmt, args); } It jus

Re: Parsing a string from stdin using formattedRead

2017-12-06 Thread Mark via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 18:57:55 UTC, Ali Çehreli wrote: On 12/06/2017 10:47 AM, Mark wrote: > string info = readln(); > formattedRead(info, "%s %s", first_name, last_name); > > This piece of code works > formattedRead(readln(), "%s %s", first_name, last_name); > > But this raises a co

Re: Parsing a string from stdin using formattedRead

2017-12-06 Thread Ali Çehreli via Digitalmars-d-learn
On 12/06/2017 10:47 AM, Mark wrote: > string info = readln(); > formattedRead(info, "%s %s", first_name, last_name); > > This piece of code works > formattedRead(readln(), "%s %s", first_name, last_name); > > But this raises a compilation error, claiming that formattedRead "cannot > deduce funct

Parsing a string from stdin using formattedRead

2017-12-06 Thread Mark via Digitalmars-d-learn
std.format has the function formattedRead which can be used to parse a string, e.g. string first_name; string last_name; string info = readln(); formattedRead(info, "%s %s", first_name, last_name); This piece of code works as intended. However, since I don't need the input after it's parsed, I

Parsing mbox file to display with vibe.d

2017-09-22 Thread Martin Tschierschke via Digitalmars-d-learn
Hello, Parsing mbox file (/var/spool/mail/... on a Ubuntu machine) and splitting to a range or array of mail objects. Has anyone done this with D? please give me hint. (DUB, git, this forum?) Or should I start with formail (-s) as a subprocess? (At first step, I want to run a vibe.d server

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
btw it is important to use right compiler with right flags I am using ldc with this flags ldmd2 -O -release -boundscheck=off On Fri, Jun 9, 2017 at 6:28 PM, uncorroded via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > On Friday, 9 June 2017 at 14:19:48 UTC, Daniel Kozak wrote:

Re: Can I speed up this log parsing script further?

2017-06-09 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 09, 2017 at 04:28:08PM +, uncorroded via Digitalmars-d-learn wrote: [...] > Is there a good resource to read about the good stuff in std.algorithm > and range? I tried going through the library docs but they are too > exhaustive! [...] Try these: http://ddili.org/ders/d.e

Re: Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
On Friday, 9 June 2017 at 14:19:48 UTC, Daniel Kozak wrote: import std.stdio; import std.array: appender, array; import std.algorithm : findSplit, splitter, joiner, canFind, map; import std.typecons : tuple, Tuple; import std.conv : to; import std.range : dropOne, dropExactly, takeExactly, chai

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
import std.stdio; import std.array: appender, array; import std.algorithm : findSplit, splitter, joiner, canFind, map; import std.typecons : tuple, Tuple; import std.conv : to; import std.range : dropOne, dropExactly, takeExactly, chain; alias push_type = Tuple!(int, char[], int, bool, bool); alia

Re: Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
On Friday, 9 June 2017 at 08:58:38 UTC, Daniel Kozak wrote: There is no difference in speed because you do not process your data lazily, so you make many allocations, so this is main reason why it is so slow. I could improve that, but I will need to see some example data, which you are trying

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Jun 9, 2017 at 9:34 AM, uncorroded via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Hi guys, > > I am a beginner in D. As a project, I converted a log-parsing script in > Python which we use at work, to D. This link was helpful - ( > https://dlan

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
Dne 9.6.2017 v 09:50 rikki cattermole via Digitalmars-d-learn napsal(a): On 09/06/2017 8:34 AM, uncorroded wrote: Hi guys, ... The code isn't entirely 1:1. Any usage of IO (includes stdout via writeln) is expensive. Your python code doesn't write anything to stdout (or perform any calls).

Re: Can I speed up this log parsing script further?

2017-06-09 Thread Daniel Kozak via Digitalmars-d-learn
; Hi guys, >> >> I am a beginner in D. As a project, I converted a log-parsing script in >> Python which we use at work, to D. This link was helpful - ( >> https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ ) I >> compiled it with dmd and ldc. The log fi

Re: Can I speed up this log parsing script further?

2017-06-09 Thread rikki cattermole via Digitalmars-d-learn
On 09/06/2017 8:34 AM, uncorroded wrote: Hi guys, I am a beginner in D. As a project, I converted a log-parsing script in Python which we use at work, to D. This link was helpful - ( https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ ) I compiled it with dmd and ldc. The log

Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
Hi guys, I am a beginner in D. As a project, I converted a log-parsing script in Python which we use at work, to D. This link was helpful - ( https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ ) I compiled it with dmd and ldc. The log file is 52 MB. With dmd (not release

Re: Command Line Parsing

2017-04-15 Thread Jon Degenhardt via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 09:51:34 UTC, Russel Winder wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt https:/

Re: Command Line Parsing

2017-04-12 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 09:51:34 UTC, Russel Winder wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt https:/

Re: Command Line Parsing

2017-04-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 09:51:34 UTC, Russel Winder wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt https:/

Re: Command Line Parsing

2017-04-12 Thread rikki cattermole via Digitalmars-d-learn
On 12/04/2017 10:51 AM, Russel Winder via Digitalmars-d-learn wrote: Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt https:/

Command Line Parsing

2017-04-12 Thread Russel Winder via Digitalmars-d-learn
Are Argon https://github.com/markuslaker/Argon or darg https://github. com/jasonwhite/darg getting traction as the default command line handling system for D or are they just peripheral and everyone just uses std.getopt https://dlang.org/phobos/std_getopt.html ? -- Russel. =

Re: Optimising JSON parsing leads to wierd execution timings

2017-03-28 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 27 March 2017 at 09:05:00 UTC, Seb wrote: On Saturday, 25 March 2017 at 06:53:58 UTC, xtreak wrote: Hi, Sorry for the double post. I have asked a question at Stackoverflow regarding this : https://stackoverflow.com/questions/42992507/get-float-value-out-of-jsonvalue-in-dlang . I ha

Re: Optimising JSON parsing leads to wierd execution timings

2017-03-27 Thread Seb via Digitalmars-d-learn
On Saturday, 25 March 2017 at 06:53:58 UTC, xtreak wrote: Hi, Sorry for the double post. I have asked a question at Stackoverflow regarding this : https://stackoverflow.com/questions/42992507/get-float-value-out-of-jsonvalue-in-dlang . I have a `rating` field that might have 3 which parses to

Optimising JSON parsing leads to wierd execution timings

2017-03-24 Thread xtreak via Digitalmars-d-learn
taking the same time. So I profiled again and now the time for JSON parsing has suddenly increased as per the profile. I thought it was due to using .type and I returned a hardcoded number for the function get_number and the time to write to terminal increased. I don't know why reducing the

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-29 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 28 January 2017 at 15:40:24 UTC, Nestor wrote: On Friday, 27 January 2017 at 04:26:31 UTC, Era Scarecrow wrote: Skipping the BOM is just a matter of skipping the first two bytes identifying it... AFAIK in some cases the BOM takes up to 4 bytes (FOR UTF-32), so when input encodin

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-28 Thread Nestor via Digitalmars-d-learn
On Friday, 27 January 2017 at 04:26:31 UTC, Era Scarecrow wrote: Skipping the BOM is just a matter of skipping the first two bytes identifying it... AFAIK in some cases the BOM takes up to 4 bytes (FOR UTF-32), so when input encoding is unknown one must perform some kind of detection in orde

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-27 Thread Era Scarecrow via Digitalmars-d-learn
On Friday, 27 January 2017 at 07:02:52 UTC, Jack Applegame wrote: On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote: static char[1024*4] buffer; //4k reusable buffer, NOT thread safe Maybe I'm wrong, but I think it's thread safe. Because static mutable non-shared variables

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-26 Thread Jack Applegame via Digitalmars-d-learn
On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote: static char[1024*4] buffer; //4k reusable buffer, NOT thread safe Maybe I'm wrong, but I think it's thread safe. Because static mutable non-shared variables are stored in TLS.

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-26 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 17 January 2017 at 11:40:15 UTC, Nestor wrote: Thanks, but unfortunately this function does not produce proper UTF8 strings, as a matter of fact the output even starts with the BOM. Also it doesn't handle CRLF, and even for LF terminated lines it doesn't seem to work for lines other

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-17 Thread Nestor via Digitalmars-d-learn
On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote: On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote: I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each iteration) without loading the entire file into

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-16 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote: I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each iteration) without loading the entire file into memory? Could... roll your own? Although if you wanted it to be

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-15 Thread Nestor via Digitalmars-d-learn
On Sunday, 15 January 2017 at 16:29:23 UTC, Daniel Kozák wrote: This is because byLine does return range, so until you do something with that it does not cause any harm :) I see. So correcting my original doubt: How could I parse an UTF16LE file line by line (producing a proper string in each

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-15 Thread Daniel Kozák via Digitalmars-d-learn
V Sun, 15 Jan 2017 14:48:12 + Nestor via Digitalmars-d-learn napsáno: > On Friday, 6 January 2017 at 11:42:17 UTC, Mike Wey wrote: > > On 01/06/2017 11:33 AM, pineapple wrote: > >> On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote: > > I'm not sure if this works quite as in

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-15 Thread Nestor via Digitalmars-d-learn
On Sunday, 15 January 2017 at 14:48:12 UTC, Nestor wrote: After some testing I realized that byLine was not the one failing, but any string manipulation done to the obtained line. Compile the following example with and without -debug and run to see what I mean: import std.stdio, std.string;

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-15 Thread Nestor via Digitalmars-d-learn
On Friday, 6 January 2017 at 11:42:17 UTC, Mike Wey wrote: On 01/06/2017 11:33 AM, pineapple wrote: On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote: I'm not sure if this works quite as intended, but I was at least able to produce a UTF-16 decode error rather than a UTF-8 decode error

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-06 Thread Mike Wey via Digitalmars-d-learn
On 01/06/2017 11:33 AM, pineapple wrote: On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote: I'm not sure if this works quite as intended, but I was at least able to produce a UTF-16 decode error rather than a UTF-8 decode error by setting the file orientation before reading it. import

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-06 Thread pineapple via Digitalmars-d-learn
On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote: I'm not sure if this works quite as intended, but I was at least able to produce a UTF-16 decode error rather than a UTF-8 decode error by setting the file orientation before reading it. import std.stdio; import core.stdc.wchar

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-05 Thread rumbu via Digitalmars-d-learn
I'm not sure if this works quite as intended, but I was at least able to produce a UTF-16 decode error rather than a UTF-8 decode error by setting the file orientation before reading it. import std.stdio; import core.stdc.wchar_ : fwide; void main(){ auto file = File("UTF-

Re: Parsing a UTF-16LE file line by line?

2017-01-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/17 6:03 AM, Nestor wrote: Hi, I was just trying to parse a UTF-16LE file using byLine, but apparently this function doesn't work with anything other than UTF-8, because I get this error: "Invalid UTF-8 sequence (at index 1)" How can I achieve what I want, without loading the entire file

Re: Parsing a UTF-16LE file line by line, BUG?

2017-01-04 Thread Daniel Kozák via Digitalmars-d-learn
Nestor via Digitalmars-d-learn napsal St, led 4, 2017 v 8∶20 : On Wednesday, 4 January 2017 at 18:48:59 UTC, Daniel Kozák wrote: Ok, I've done some testing and you are right byLine is broken, so please fill a bug A bug? I was under the impression that this function was *intended* to work onl

  1   2   3   >