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).
<-lookup
and syntax_table<-convert.->match
for each start of a physical line and should succeed if the lines
separates two paragraphs. The default is’\s *$’,
implying a line containing only layout characters.
See also syntax_table->sentence_end.
and text_buffer<-scan.
Defaults: The default regex describes an empty line: regex('\s *$').
<-scan, editor->forward_sentence editor ->backward_sentence' and editor syntax_table->fill‘.
->syntax, syntax_table->has_syntax,
etc. See also
syntax_table<-context.
or on the table entry, placing the
character in multiple categories. If a context is specified it replaces
the defined context. See also syntax_table->syntax.
Bugs: A character may be in any number of syntactical categories but only has one context character defined.
->syntax
or syntax_table->add_syntax.->initialise.syntax_name.Anonymous tables are not stored in @syntax_tables.
<-kind
for a description on type char. Type syntax_name is a name_of
type that allows for the following syntactical categories.
Category Context Default table
=========================================
uppercase_letter -- A-Z
lowercase_letter -- a-z
digit -- 0-9
word_separator -- _
symbol --
open_bracket close ([{
close_bracket open }])
end_of_line -- \C-j
white_space -- \C-a - \C-i, \C-k - SPC, DEL - M-DEL
string_quote escape "'
punctuation -- !#$%&*+,-./:;<=>?\^|~
end_of_string -- \C-@
comment_start end
comment_end start
letter -- uppercase_letter|lowercase_letter
word -- letter|digit|word_separator|symbol
layout -- end_of_line|white_space
Notes:
\’(backslash), for Prolog
this is the quote itself.
comment_start , comment_end->for_all_comments.
syntax_table->syntax
makes the table forget anything defined for this character.
syntax_table->add_syntax
may be used to specify a character into multiple syntactical categories.
See also text_buffer->syntax
and class editor.
Diagnostics: Fails silently if no such comment sequence is defined.
Diagnostics: Fails silently if no such comment sequence is defined.
->syntax).
The context characters are stored in this C-array.->initialise.|chain<-context.