Parsing error!

May 20, 2008
11,411
99
Syracuse, NY, USA
I expected TCC to handle this easily. But ...

Code:
v:\> set z=2

v:\> for /l %i in (1,1,%@eval[(%z + 4) / 2]) echo %i
TCC: Syntax error "@eval[(%z + 4"
 
May 20, 2008
3,515
4
Elkridge, MD, USA
vefatica wrote:
| ---Quote (Originally by vefatica)---
|| I expected TCC to handle this easily. But ...
||
||
|| Code:
|| ---------
|| v:\> set z=2
||
|| v:\> for /l %i in (1,1,%@eval[(%z + 4) / 2]) echo %i
|| TCC: Syntax error "@eval[(%z + 4"
|| ---------
| ---End Quote---

Verified here in all versions going back to 6.01.245U. I suspect the parser
looks at the brackets surrounding the function parameters as a
character-selection wildcard, in which role it is, of course, wrong.

| Why didn't I get that post in the mail?

I did not get it, either! So many of my emailed posts to
tc_suggestions@jpsoft.com were never returned that I started sending them to
this NG (which may be useless to do, as Rex reported that he ignores this NG
when looking for suggestions). I think there is a serious flaw in at least
one of the mechanisms which post email messages into the browsable database,
and which email new posts. Another issue is that for those of us whose
registered name in the browser is not representable in ASCII (e.g. Péter
Köves), the non-ASCII letters are just snuffed out by the "remailer", and
e.g. my name shows up as Fbin. I am CC*ing myself on this message, to see
whether or not this last issue is due to how Outlook Express handles my
incoming mail.
--
Steve Fábián
 
May 20, 2008
11,411
99
Syracuse, NY, USA
On Sat, 19 Dec 2009 07:07:20 -0600, Steve Fábián <> wrote:

|Verified here in all versions going back to 6.01.245U. I suspect the parser
|looks at the brackets surrounding the function parameters as a
|character-selection wildcard, in which role it is, of course, wrong.

No, functions are fine:

v:\> for /l %i in (1,1,%@eval[1+2]) echo %i
1
2
3

Parens inside of functions are not. I figured they'd be protexted.

v:\> for /l %i in (0,1,%@len[%z]) echo %i
0
1
2

v:\> for /l %i in (0,1,%@len[a(bc)d]) echo %i
TCC: Syntax error "@len[a(bc"
--
- Vince
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
> vefatica wrote:
> | ---Quote (Originally by vefatica)---
> || I expected TCC to handle this easily. But ...
> ||
> ||
> || Code:
> || ---------
> || v:\> set z=2
> ||
> || v:\> for /l %i in (1,1,%@eval[(%z + 4) / 2]) echo %i
> || TCC: Syntax error "@eval[(%z + 4"
> || ---------
> | ---End Quote---
>
> Verified here in all versions going back to 6.01.245U. I suspect the
> parser
> looks at the brackets surrounding the function parameters as a
> character-selection wildcard, in which role it is, of course, wrong.

No -- it's seeing the close paren as the end of the FOR argument list. FOR
is not expecting (or supporting) nested parentheses.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,466
88
Albuquerque, NM
prospero.unm.edu
I expected TCC to handle this easily. But ...

Code:
v:\> set z=2
 
v:\> for /l %i in (1,1,%@eval[(%z + 4) / 2]) echo %i
TCC: Syntax error "@eval[(%z + 4"

You can escape the close paren that's confusing FOR:

Code:
for /l %i in (1,1,%@eval[(%z + 4 %=) / 2]) echo %i
That said, it might be better to just split it into two commands.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
rconn wrote:
| No -- it's seeing the close paren as the end of the FOR argument
| list. FOR is not expecting (or supporting) nested parentheses.

Given that the current directory contains subdirectory ab(c), I observed
that
for %x in ( ab(c)\* ) echo %x
fails, but
for %x in ( "ab(c)\*" ) echo %x
works. However, neither tab completion nor the function %@quote[ab(c)\*]
adds the quotation marks to allow the FOR command to work. As much as I
shudder about using such directory names, people do use them. IMHO any file
name which gives the parser problems unless quoted should be quoted by both
tab completion and @QUOTE.

Additional suggestion: a new editing keystroke to emulate @QUOTE, analogous
to the keystroke which converts LFN to SFN.
--
Steve
 
May 20, 2008
11,411
99
Syracuse, NY, USA
On Sat, 19 Dec 2009 10:33:10 -0600, Charles Dye <> wrote:

|You can escape the close paren that's confusing FOR:
|
|
|Code:
|---------
|for /l %i in (1,1,%@eval[(%z + 4 %=) / 2]) echo %i
|---------
|That said, it might be better to just split it into two commands.

Maybe so for @EVAL, but in other functions, it will give an incorrect result.

v:\> for /l %i in (0,1,%@len[a(bc)d]) echo %i
TCC: Syntax error "@len[a(bc"

v:\> set z=a(bc)d

v:\> for /l %i in (0,1,%@len[%z]) echo %i
0
1
2
3
4
5
6

v:\> for /l %i in (0,1,%@len[a(bc^)d]) echo %i
0
1
2
3
4
5
6
7
--
- Vince
 
May 20, 2008
11,411
99
Syracuse, NY, USA
On Sat, 19 Dec 2009 11:04:50 -0600, Steve Fábián <> wrote:

|but
| for %x in ( "ab(c)\*" ) echo %x
|works.

I'm very surprised that quotes protect the paren while being inside a function
doesn't.

Suggestion for the next version: command line DO
--
- Vince
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
On Sat, 19 Dec 2009 11:04:50 -0600, Steve Fábián <> wrote:

|but
| for %x in ( "ab(c)\*" ) echo %x
|works.

I'm very surprised that quotes protect the paren while being inside a function doesn't.

- Vince

Since the FOR argument processing and the variable function expansion are about 50,000 lines of code apart, it's not too surprising to me!

This would require a separate parser just for FOR to preprocess the argument list in the .0000001% of cases where somebody wants to use a variable function with embedded parentheses. (God forbid that the user would decide to use unmatched parentheses...)
 
Similar threads
Thread starter Title Forum Replies Date
D Parsing an array variable to an array does not work Support 5
vefatica IF, @WMI, parsing? Support 7
M Command line parsing differences between cmd.exe and TCC Support 6
nickles Command name parsing of GNU compilers Support 13
J Python: TCC command line parsing removes '=' equal sign characters Support 4
H command line parsing question Support 5
cgunhouse One of the Focuses of V17 Beta Testing Should Be Command Line Parsing Support 1
M How to? Parsing lines containing double quotes... Support 3
Stefano Piccardi parsing issue in command GLOBAL Support 3
C CMD if parsing Support 2
M A probably stupid question about .btm file argument parsing... Support 6
S New "home" variable parsing issue Support 1
samintz Help with some parsing Support 6
nikbackm Parsing problem? (IFF, "", &) Support 0
C Copy (sys) error Support 3
T Error: This page can’t be displayed Make sure the web address //ieframe.dll/dnserrordiagoff.htm# is correct. Support 8
kb6ojs How to? "Specified Account Already Exists" error installing TCMD v27 Support 12
samintz How to? Abort on error DO loop Support 10
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica ON ERROR terminates DO loop. Support 0
C Google intregration error Support 4
C FB intregration error Support 0
gworley rd (Remove Directory) gives interesting error: Support 2
D How to? Skip removing directory (RMDIR) without error message Support 2
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
M Strange error messages from TCC in FTP copy Support 7
vefatica Error message from TOUCH Support 2
R FIND command error Support 9
fpefpe Python dll error Support 3
D error in help documentation? Support 0
R FOR usage error from TCC but not from CMD Support 16
K_Meinhard Help file error Support 1
X small translation error. Support 0
W pdir returns diff results between tcc and tcmd - one is an error msg Support 5
Dmitry L. Kobyakov From old version: had the setup's error been corrected? Support 6
vefatica Why no error message? Support 2
vefatica ON ERROR and pipes? Support 8
MickeyF Why does this batch file give me 'unknown command "else"' error? Support 17
Joe Caverly TASKDIALOG Help link error Support 1
J Error "Contents lost before copy" Support 3
vefatica What's causing this error? Support 4
vefatica Error 203? Support 4
C Activation Error. Support 2
J Error running Python at command line Support 9
Joe Caverly PSHELL Error? Support 16
M Fixed PSHELL command returns error Support 2
vefatica REGDIR, strange error message Support 7
O Error in plugin /u Support 2
O TPIPE: Error -Can´t access textpipeengine.dll Support 24
fpefpe How to? script error Support 1

Similar threads