[ Syntax Settings | Reference Manual | Alphabetic Index ]

# local chtab(+Char, +Class)

# export chtab(+Char, +Class)

# set_chtab(+Char, +Class)

Sets the lexical class of character Char to class Class, this provides an interface to ECLiPSe 's lexical analyser.

Char
  Integer in range 0 to 255.
Class
  Atom indicating the character class.

## Description

Changes the lexical class of a given character. This is especially useful for implementing compatibility packages.

Char must be an integer character code, which would typically be written in character-quote syntax, eg `0'a` instead of `98`.

Class is the name of a character class. The following table lists the existing character classes and the default set of characters in that class:

     Class          Default member characters
    ---------------------------------------------------------
     upper_case     all upper case letters
     underline      _
     lower_case     all lower case letters
     digit          digits
     blank_space    space, tab and nonprintable characters
     end_of_line    newline (NL)
     atom_quote     '
     string_quote   "
     list_quote	`
     chars_quote
     radix
     ascii
     solo           ! ;
     special        ( [ { ) ] } , |
     line_comment   %
     escape         \
     first_comment  /
     second_comment *
     symbol         # + - . : < = > ? @ ^ ~ & $
     terminator

The table corresponds to the default eclipse_language settings. Using other language dialects typically changes some of the assignments on a module-local basis (e.g. for the iso dialect, the meaning of single and double quotes is reversed).

It is not recommended to change the class of the special characters, since in some cases it might make it impossible to correctly parse Prolog terms.

Note: the default class of the back-quote character ` was changed from symbol to list_quote in ECLiPSe 7.0.

### Modes and Determinism

- set_chtab(+, +) is det

### Modules

This predicate is sensitive to its module context (tool predicate, see @/2).

### Exceptions

(4) instantiation fault
  Char and/or Class are not instantiated.
(5) type error
  Char is not an integer in the range 0 to 255.
(6) out of range
  Class is not a valid lexical class.

## Examples

    Success:
       % The following example illustrates the use
       % of set_chtab/2 to redefine the class of the
       % dollar symbol.
       %
       [eclipse]: X = $a.
                     ^ (here?)
       syntax error: postfix/infix operator expected
       [eclipse]: set_chtab(0'$, lower_case).

       yes.
       [eclipse]: X = $a.

       X = $a
       yes.
       [eclipse]:

    Error:
       set_chtab("a",symbol).       (Error 5)
       set_chtab(97,fred).          (Error 6)

## See Also

local / 1, export / 1, get_chtab / 2, read_token / 2, read_token / 3