src/swipl-devel/packages/xpce/man/refmanual/md/syntax_table.md

class syntax_table {#class-syntax_table}

Class syntax_table describes syntactical properties of (programming) languages. It is used by class editor and class text_buffer to realise syntax driven editors. Class tokeniser used syntax tables to determine tokens and skip comment.

Syntax-tables are named reusable objects (like -for example- colours or fonts). The default syntax table is named default.

The code below defines a syntax table for PCE/Prolog programs:

?- new(X, syntax_table(prolog)),
   send(X, syntax, '"',  string_quote, '"'),
   send(X, syntax, '''', string_quote, ''''),
   send(X, syntax, @,    symbol),

   send(X, syntax,     '%',  comment_start),
   send(X, add_syntax, '\n', comment_end),
   send(X, add_syntax, '/',  comment_start, '*'),
   send(X, add_syntax, '*',  comment_end, '/').

After this definition, the following call associates this syntax table to an editor (view):

?- new(X, view),
   send(X, syntax, prolog).

Instance variables {#class-syntax_table-instvars}

Send methods {#class-syntax_table-send}

Get methods {#class-syntax_table-get}



Try the rswipl package in your browser

Any scripts or data that you put into this service are public.

rswipl documentation built on June 16, 2026, 5:07 p.m.