Unexpected preprocessor parsing

Discussion related to "Everything" 1.5 Alpha.
Post Reply
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Unexpected preprocessor parsing

Post by NotNull »

v1388a


addcol:A A:=#[left:"c:\windows\system32"#,:2#]:
=> A = "c" (1 char instead of 2)
FWIW, without quotes ( #[left:c:\windows\system32#,:2#]: ), column A stays empty.

However: (len: instead of left:)
addcol:A A:=#[len:"c:\windows\system32"#]:
=> A = "21" (includes the "" quotes)
But:
addcol:A A:=[len:"c:\windows\system32"]
=> A = "19" (without the quotes)

Similar issues with preprocessor function with multiple arguments, like:
addcol:A,B A:=#[and:1#,:1#,:1#]: B:="something"
=> A = "1#,:1#,:1#]:"
A:=#[concatenate:textA#,:textB#,:textC#]:



EDIT: Installed 1389a: same behaviour.
win32
Posts: 12
Joined: Fri Mar 19, 2021 11:48 am

Re: Unexpected preprocessor parsing

Post by win32 »

I think in the first case it counts the starting quote in second case it doesnt parse at all.
David did some renovation in the syntax, I had some breakage, but I advise you use the newer syntax: #left:<"c:\windows\system32",2> which works even without quotes and is gentler to the eyes! :)
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Unexpected preprocessor parsing

Post by NotNull »

Thanks for the ideas, @win32!
What version of Everything 1.5 are you running? There have been some changes in the preprocessor parsing recently.

In v1389a, the suggested query -- addcol:A A:=#left:<"c:\windows\system32",2> -- gives an empty column A here.

What is even mor unexpected:
addcol:A A:=#left:<"c:\windows\system32",5>
=> A = "\wi"


BTW: This <> syntax is a bit harder to use in scripts or on the command-line as the redirection symbols < and > need to be taken special care of to prevent redirecting.
win32
Posts: 12
Joined: Fri Mar 19, 2021 11:48 am

Re: Unexpected preprocessor parsing

Post by win32 »

My current version is v1388a.
My breakage happened in the upgrade from the summer build to the first winter builds, but since I have resolved the issues.
Before making the post I tested my answer in the search edit using the fwd slash syntax /#left:<"c:\windows\system32",2> .
this works here: addcolumn:a a:="#left:c:\windows\system32,2" , with or without <>/ inner quotes
I also wanted to cite void's post but I couldnt find it, I only found a post about <func:arg1,..> syntax, but I think there was a more detailed post about the recent changes.
void
Developer
Posts: 17149
Joined: Fri Oct 16, 2009 11:31 pm

Re: Unexpected preprocessor parsing

Post by void »

To test #[function:...#]: syntax, in the Everything search box type in the following:

/#[left:"c:\windows\system32"#,:2#]:


The result is shown in the window title bar.



#[left:"c:\windows\system32"#,:2#]:
=>
"c


#[function:...#]: syntax style will treat quotes as literal.



#[left:#[removequotes:"c:\windows\system32"#]:#,:2#]:
=>
c:




The recommended syntax is:
[left:"c:\windows\system32",2]
=>
c:
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Unexpected preprocessor parsing

Post by NotNull »

Thanks. Some of those give the expected results with the "/" syntax.

For some background: I am in the process of figuring out and describing the different phases of parsing search queries.
Everything 1.5 has a lot more search possibilities and with that, serach queries can get longer and more complex.
Especially with nested preprocessor-/"column"-/search-functions.
Recently a lot of the search queries I produce can be measured in meters instead of words (figure of speech).

So knowing the details of the parsing could really help in troubleshooting those.
This was just "Step 1" in trying to figure this out. So I still really like to know *why* the A:=#[ .. syntax fails, even though I don't actually need it.
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: Unexpected preprocessor parsing

Post by NotNull »

An example: How can I make the following work?

Idea is to find pairs n the same folder that have the same stem, in this example exe and ini files i, i.e. Everything.exe and Everything.ini
(eventually this will become a pairs: filter)

Code: Select all

[define:input="exe;ini"]  ext:[input:]  [substitute:;[input:],";","  exact:fileexists:$stem:."]  dupe:path
If all went well, it should expand to:
ext:exe;ini exact:fileexists:$stem:.exe exact:fileexists:$stem:.ini dupe:path
void
Developer
Posts: 17149
Joined: Fri Oct 16, 2009 11:31 pm

Re: Unexpected preprocessor parsing

Post by void »

So I still really like to know *why* the A:=#[ .. syntax fails, even though I don't actually need it.
#[:...#]: preprocessor treats double quotes (") literally.



To expand
[substitute:;[input:],";"," exact:fileexists:$stem:."]
to multiple search terms you will need to use the #[:...#]: preprocessor.

#[define:input=exe;ini#]: ext:#input: #[substitute:;#input:#,:;#,: exact:fileexists:$stem:.#]: dupe:path
Post Reply