Highlighting doesn't know characters aren't strings of chars

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
PhilippaC
Posts: 3
Joined: Sun Jun 03, 2007 6:09 pm

Highlighting doesn't know characters aren't strings of chars

Post by PhilippaC »

Syntax highlighting doesn't seem to know that characters (unlike strings) consist of exactly one character. This is a problem in languages where ' is both a valid part of an identifier and the character delimiter - for example, it's not uncommon to see identifiers like f, f', f'' etc in Haskell where it follows a mathematical tradition and having two such identifiers on the same line messes up the highlighting.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Re: Highlighting doesn't know characters aren't strings of c

Post by MudGuard »

PhilippaC wrote:Syntax highlighting doesn't seem to know that characters (unlike strings) consist of exactly one character.
This is because in some languages a character representation consists of more than one character.

Examples:
HTML: ä represents ä.
XML:   represents a non-breakable space.
C/C++/Java: \' represents the ' character.
Many languages: \t represents the tab character.
...
PhilippaC
Posts: 3
Joined: Sun Jun 03, 2007 6:09 pm

Post by PhilippaC »

Given that escapes're being handled already, there's already a notion of token or character literal involved as well as sourcetext characters - it's perfectly viable for highlighting to recognise exactly one of those in characters as opposed to strings.
Post Reply