[Swift-devel] app syntax ambiguity

Ben Clifford benc at hawaga.org.uk
Sun Dec 16 07:38:34 CST 2007


Expressions have been mostly self delimiting, which is useful in the app{} 
block syntax where there are no delimiters between the parameters of an 
application. For example, given the input: 21*33 14*96 that can be parsed 
as two expressions, the first one 21*33 and the second one 14*96.

The sequence of tokens for this coming out of the lexer is: 21 * 33 14 * 
96

There's some ambiguity when it comes to unary +/- eg 21 -33 could be 
either a single expression (21-33) or two expressions 21 and -33.

However, no one has commented on having trouble with this before.

Putting in multi-dimensional array support adds more ambiguity along the 
same lines, this time interacting with array literals.

i[1][2] might mean two parameters i[1] and an array literal [2] or it 
might mean one parameter accessing a multidimensional array i[1][2].

Changing the syntax used to specify array literals would resolve this, as 
would putting in specific delimiters in the app block. The former is 
probably the least intrusive in terms of already written user scripts.

-- 



More information about the Swift-devel mailing list