edn-format / edn

Extensible Data Notation
2.62k stars 96 forks source link

Are +, - and . valid symbols? #54

Closed igorw closed 10 years ago

igorw commented 11 years ago

The spec currently reads (emphasis mine):

Symbols begin with a non-numeric character and can contain alphanumeric characters and . * + ! - _ ? $ % & =. If -, + or . are the first character, the second character must be non-numeric. Additionally, : # are allowed as constituent characters in symbols other than as the first character.

This implies that +, - and . must have at least one non-numeric character following as part of the symbol. It should be reworded to clarify that those characters are also valid as single-character symbols.

bpsm commented 11 years ago

FWIW, edn-java allows -, + and . as symbols and interprets the passage as:

If -, + or . are the first character, the second character (if present) must be non-numeric.

The implementation considers anything beginning with - or + followed by a digit a number and attempts to parse it as such. If this fails, it must have been an invalid symbol. - or + followed by a non-digit is a symbol. There's a special case check for . followed by a digit that takes place after otherwise successful recognition of a symbol.

(But there's a bug such that it currently accepts symbols of the form prefix/+name: bpsm/edn-java#36)