# Re: \[personal kdb+\] what's up with parse?

**URL:** <https://forum.kx.com/t/re-personal-kdb-whats-up-with-parse/6197>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [August 21, 2009, 2:43pm UTC](https://forum.kx.com/t/re-personal-kdb-whats-up-with-parse/6197 "2009-08-21T14:43:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manni\_patel](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@manni\_patel](https://forum.kx.com/u/manni_patel)\
**Post date:** [August 21, 2009, 2:43pm UTC](https://forum.kx.com/t/re-personal-kdb-whats-up-with-parse/6197/1 "2009-08-21T14:43:00Z")

</div>

Reply-To: manni.patel@gmail.comX-Priority: NormalSensitivity: NormalImportance: NormalSubject: Re: [personal kdb+] what’s up with parse?To: personal-kdbplus@googlegroups.comFrom: “Manish Patel” \<manni.patel\>Date: Fri, 21 Aug 2009 13:43:02 +0000eW91IG5lZWQgdG8gZXNjYXBlIHRoZSBcIHdpdGggYW4gZXh0cmEgXCAgLCBidXQgSSBndWVzcyBwYXJzZSBzaG91bGQgZG8gdGhhdCBhdXRvbWF0aWNhbGx5DQoNCg0KLS0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tLQ0KRnJvbTogYW5keXR1cmsNClNlbmRlcjogcGVyc29uYWwta2RicGx1c0Bnb29nbGVncm91cHMuY29tDQpUbzogS2RiKyBQZXJzb25hbCBEZXZlbG9wZXJzDQpSZXBseVRvOiBwZXJzb25hbC1rZGJwbHVzQGdvb2dsZWdyb3Vwcy5jb20NClN1YmplY3Q6IFtwZXJzb25hbCBrZGIrXSB3aGF0J3MgdXAgd2l0aCBwYXJzZT8NClNlbnQ6IDIxIEF1ZyAyMDA5IDE0OjM4DQoNCg0KSXQgc2VlbXMgdGhhdCBwYXJzZSBjYW4ndCBwYXJzZSAoc29tZSkgdmFsaWQgZXhwcmVzc2lvbnMuIEZvcg0KZXhhbXBsZS4uLg0KDQpxKTEgMiwvOjMNCjQNCjEgMiAzDQoxIDIgNA0KcSlwYXJzZSAiMSAyLC86Mw0KNCINCi86ICwNCjEgIDINCjMgIDQNCnEpMSAyLC86XDozDQo0DQoxIDMgMSA0DQoyIDMgMiA0DQpxKXBhcnNlICIxIDIsLzpcOjMNCjQiDQonIjEgMiwvOlw6MyA0Ig0KDQoNCg0KDQpTZW50IHVzaW5nIEJsYWNrQmVycnmuIGZyb20gT3Jhbmdl\</manni.patel\>

---

<div class="post-metadata">

**Author:** ![andyturk](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andyturk](https://forum.kx.com/u/andyturk)\
**Post date:** [August 21, 2009, 2:57pm UTC](https://forum.kx.com/t/re-personal-kdb-whats-up-with-parse/6197/2 "2009-08-21T14:57:00Z")

</div>

On Aug 21, 8:43?pm, “Manish Patel” \<manni.pa…\> wrote:\> you need to escape the \ with an extra \Doh!KDB+ 2.5 2009.08.05 Copyright (C) 1993-2009 Kx Systemsm32/ 2()core 4096MB andy andy-turks-macbook-pro.local 10.211.55.2 PLAY2009.11.03q)parse “1 2,/:\: 3 4”: (/:;,)1 23 4q)I thought the error was coming from my explicit call to parse. Nope.The main loop parser choked before it got there.\</manni.pa…\>

---

<div class="post-metadata">

**Author:** ![andyturk](https://avatars.discourse-cdn.com/v4/letter/a/e5b9ba/32.png) [@andyturk](https://forum.kx.com/u/andyturk)\
**Post date:** [August 22, 2009, 2:20am UTC](https://forum.kx.com/t/re-personal-kdb-whats-up-with-parse/6197/3 "2009-08-22T02:20:00Z")

</div>

Last night, I wrote…\> The main loop parser choked before it got there.This morning, with somewhat refreshed eyes, I looked at the earlierdiscussion and thought, “Why wouldn’t ,/:: (the original problem)simply reduce to ,/:: within the quotes?” In other words, the main-loop parser got a valid expression and the invoked parser was the onethat died. So for kicks, I try:q)parse “1 2,/::3 4”/: ,1 23 4It parsed! How strange.q)1 2,/::3 41 2 31 2 4Apparently, ,/:: has the same meaning as ,/:. I don’t understand why,but at least it parses and evaluates. At this point, I was completelyconfused. Given that “1 2,/::3 4” is parseable and valid q, why isn’t"1 2,/::3 4" equivalent? A little experimentation yielded the answer.q’s parser chokes if (within a string) you try to escape a characterthat isn’t escapable. This is different than other languages, where \Xreduces to X when X is a garden variety character. E.g., in C, “\G” isthe same string as “G”. In q, however, “\G” isn’t a valid string.Which means that…The originally offending code, “1 2,/::3 4” caused a parsing error inthe main loop because : is not escapable. I’m guessing that behaviorhelps coders find problems more quickly, since \ has multipleinterpretations.But that leaves the mystery over ,/:: How many colons can we have?q)parse “1 2,/::::::::::3 4”/: ,1 23 4Apparently, quite a lot. ;-)
