Dict colon operator precedence vs unary -

?- X= tag{x: -100}.
X = tag{x: -100}.

?- X= tag{x:-100}.   % No space
ERROR: Syntax error: colon_expected
ERROR: X= tag{
ERROR: ** here **
ERROR: x:-100} . 

Is it expected?

The tokenizer is “greedy”, so it’ll consume :- and won’t backtrack for the alternative of : and -. There are many multi-character tokens in Prolog, such as >=, \==, etc. and they all follow this principle.

2 Likes

Yip. To be more precise, a sequence of symbol characters forms an atom. The symbol characters are accessible using char_type/2:

?- char_type(X, prolog_symbol).
X = # ;
X =  ($) ;
X = & ;
X =  (*) ;
...

That continues with a long list of Unicode characters. I’m not all that sure this is a good idea. Many of these are symbols on their own and should probably be classified as solo characters (such as !). See Unicode Prolog source for details.

3 Likes