Skip to content

Commit

Permalink
Add syntax coloring support for the new error throwing built-in methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoura committed Nov 13, 2017
1 parent eee3258 commit c29fac5
Show file tree
Hide file tree
Showing 29 changed files with 217 additions and 86 deletions.
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Expand Up @@ -49,6 +49,11 @@ Tests

* ADDED: Unit tests for the new error throwing built-in methods.

IDEs, text editors, and syntax highlighters support
---------------------------------------------------

* ADDED: Syntax coloring support for the new error throwing built-in methods.


3.13.0 - November 8, 2017
=========================
Expand Down
7 changes: 4 additions & 3 deletions coding/emacs/logtalk.el
Expand Up @@ -4,8 +4,8 @@

;; Author: Paulo Moura <pmoura@logtalk.org>
;; Creation date: November 15, 2003
;; Last modification date: June 29, 2017
;; Version: 1.33
;; Last modification date: November 13, 2017
;; Version: 1.34

;; Installation:
;;
Expand All @@ -27,7 +27,7 @@

;; setup

(defvar logtalk-mode-version "1.33"
(defvar logtalk-mode-version "1.34"
"Logtalk mode version number")

(defvar logtalk-mode-hook nil)
Expand Down Expand Up @@ -135,6 +135,7 @@
("\\<\\(ca\\(?:ll\\|tch\\)\\|throw\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face)
("\\<\\(fa\\(?:il\\|lse\\)\\|true\\)\\>" 0 'logtalk-built-in-predicate-face)
("\\(!\\|->\\|;\\)" 0 'logtalk-built-in-predicate-face)
("\\<\\(\\(?:instantiation\\|type\\|domain\\|existence\\|permission\\|representation\\|evaluation\\|resource\\)_error\\)\\([(]\\)" 1 'logtalk-built-in-predicate-face)
;;
;; multi-threading:
;;
Expand Down
4 changes: 4 additions & 0 deletions coding/geshi/logtalk.php
Expand Up @@ -12,6 +12,8 @@
*
* CHANGES
* -------
* 2017/11/13 (1.1.21)
* - Added syntax coloring of the error throwing built-in methods
* 2017/06/29 (1.1.20)
* - Added syntax coloring of the context/1 method
* 2016/06/18 (1.1.19)
Expand Down Expand Up @@ -170,6 +172,8 @@
'abolish', 'asserta', 'assertz', 'clause', 'retract', 'retractall',
// control
'call', 'catch', 'ignore', 'once', 'throw',
'instantiation_error', 'type_error', 'domain_error', 'existence_error', 'permission_error',
'representation_error', 'evaluation_error', 'resource_error'
// all solutions predicates
'bagof', 'findall', 'forall', 'setof',
// multi-threading predicates
Expand Down
14 changes: 11 additions & 3 deletions coding/geshi/source.php
Expand Up @@ -49,9 +49,9 @@
extends(parent)).
:- info([
version is 1.36,
version is 1.37,
author is 'Paulo Moura',
date is 2017/06/29,
date is 2017/11/13,
comment is 'Sample prototype for testing syntax coloring.'
]).
Expand Down Expand Up @@ -200,7 +200,15 @@ enumerating_properties :-
exception_methods :-
catch(Goal, Error, Catcher),
throw(Error).
throw(Error),
instantiation_error,
type_error(Type, Culprit),
domain_error(Domain, Culprit),
existence_error(Thing, Culprit),
permission_error(Operation, Permission, Culprit),
representation_error(Flag),
evaluation_error(Exception),
resource_error(Resource).
all_solutions_methods :-
bagof(Term, Goal, List),
Expand Down
1 change: 1 addition & 0 deletions coding/gtksourceview2/logtalk.lang
Expand Up @@ -255,6 +255,7 @@
<!-- Logic and control -->
<keyword>(ca(ll|tch)|ignore|once|throw)(?=[(])</keyword>
<keyword>(true|fa(il|lse)|repeat)(?![-!(^~])</keyword>
<keyword>((instantiation|type|domain|existence|permission|representation|evaluation|resource)_error)(?=[(])</keyword>
<!-- Atomic term processing -->
<keyword>(atom_(length|c(hars|o(ncat|des))))(?=[(])</keyword>
<keyword>(sub_atom)(?=[(])</keyword>
Expand Down
1 change: 1 addition & 0 deletions coding/highlight/lgt.lang
Expand Up @@ -62,6 +62,7 @@ $KEYWORDS(kwc)=regex((a(bolish|ssert(a|z)))(?=[(]), 1)
# control
$KEYWORDS(kwc)=regex((throw|ca(ll|tch))(?=[(]), 1)
$KEYWORDS(kwc)=regex((fa(il|lse)|true), 1)
$KEYWORDS(kwc)=regex(((instantiation|type|domain|existence|permission|representation|evaluation|resource)_error)(?=[(]), 1)
# all solutions
$KEYWORDS(kwc)=regex((bagof|setof|findall|forall)(?=[(]), 1)
# multi-threading predicates
Expand Down
7 changes: 5 additions & 2 deletions coding/idea/src/org/logtalk/intellij/psi/Constants.java
Expand Up @@ -24,8 +24,11 @@ public class Constants {
"uses" , "alias" , "coinductive" , "discontiguous" , "dynamic" , "meta_predicate" , "meta_non_terminal" , "mode" ,
"multifile" , "private" , "protected" , "public" , "synchronized" , "use_module" ,
"context", "parameter" , "self" , "sender" , "this" , "current_op" , "current_predicate" , "predicate_property" , "abolish" , "asserta" ,
"assertz" , "clause" , "retract" , "retractall" , "call" , "once" , "catch" , "throw" , "bagof" , "findall" , "forall" ,
"setof" , "before" , "after" , "forward" , "phrase" , "expand_term" , "term_expansion" , "expand_goal" ,
"assertz" , "clause" , "retract" , "retractall" , "call" , "once" , "catch" , "throw" ,
"instantiation_error" , "type_error" , "domain_error" , "existence_error" ,
"permission_error" , "representation_error" , "evaluation_error", "resource_error" ,
"bagof" , "findall" , "forall" , "setof" ,
"before" , "after" , "forward" , "phrase" , "expand_term" , "term_expansion" , "expand_goal" ,
"goal_expansion" , "coinductive_success_hook" , "ask_question" , "message_hook" ,
"message_prefix_stream" , "print_message" , "print_message_tokens" , "print_message_token" , "question_hook" , "question_prompt_stream",
"call" , "message_tokens" ,
Expand Down
5 changes: 3 additions & 2 deletions coding/jedit/logtalk.xml
Expand Up @@ -7,13 +7,13 @@
written by Paulo Moura
version 1.700
created on May 5, 2002
last revised June 29, 2017
last revised November 13, 2017
To install, copy this file to the "modes" subdirectory in jEdit
directory installation. Next, check the "catalog" file in the
same subdirectory and add (if not present) the following entry:
<MODE NAME="logtalk" FILE="logtalk.xml" FILE_NAME_GLOB="*.{lgt}" />
<MODE NAME="logtalk" FILE="logtalk.xml" FILE_NAME_GLOB="*.{lgt,logtalk}" />
-->

<MODE>
Expand Down Expand Up @@ -86,6 +86,7 @@
<!-- Control -->
<SEQ_REGEXP AT_WORD_START="TRUE" TYPE="KEYWORD2">\b(ca(ll|tch)|throw)(?=[(])</SEQ_REGEXP>
<SEQ_REGEXP AT_WORD_START="TRUE" TYPE="KEYWORD2">\b(fa(il|lse)|true)\b</SEQ_REGEXP>
<SEQ_REGEXP AT_WORD_START="TRUE" TYPE="KEYWORD2">\b(instantiation|type|domain|existence|permission|representation|evaluation|resource)_error(?=[(])</SEQ_REGEXP>
<!-- All solutions -->
<SEQ_REGEXP AT_WORD_START="TRUE" TYPE="KEYWORD2">\b((bag|set)of|f(ind|or)all)(?=[(])</SEQ_REGEXP>
<!-- Multi-threading predicates -->
Expand Down
1 change: 1 addition & 0 deletions coding/kate/logtalk.xml
Expand Up @@ -41,6 +41,7 @@
<!-- Control -->
<RegExpr String = "\b(ca(ll|tch)|throw)(?=[(])" attribute = "Built-in" context = "#stay" />
<RegExpr String = "\b(fa(il|lse)|true)\b" attribute = "Built-in" context = "#stay" />
<RegExpr String = "\b(instantiation|type|domain|existence|permission|representation|evaluation|resource)_error(?=[(])" attribute = "Built-in" context = "#stay" />
<!-- All solutions -->
<RegExpr String = "\b((bag|set)of|f(ind|or)all)(?=[(])" attribute = "Built-in" context = "#stay" />
<!-- Multi-threading predicates -->
Expand Down
3 changes: 2 additions & 1 deletion coding/nedit/logtalk.pats
Expand Up @@ -2,7 +2,7 @@
!
! Author: Paulo Moura (pmoura at logtalk.org)
!
! Last changed in: June 29, 2017
! Last changed in: November 13, 2017
!
!
! To install this patterns file:
Expand Down Expand Up @@ -35,6 +35,7 @@ nedit.highlightPatterns: Logtalk:1:0{\n\
External call:"[{}]":::Keyword::\n\
Control constructs:"!|;|\\-\\-\\>|\\-\\>|<(true|fail|false)>":::Subroutine::\n\
Control constructs:"<(call|catch|throw)(?=[(])":::Subroutine::\n\
Control constructs:"<(instantiation_error|type_error|domain_error|existence_error|permission_error|representation_error|evaluation_error|resource_error)(?=[(])":::Subroutine::\n\
Block comment:"/\\*":"\\*/"::Comment::\n\
Line comment:"%":"$"::Comment::\n\
Number:"0'.":::Numeric Const::\n\
Expand Down
36 changes: 22 additions & 14 deletions coding/npp/logtalk.api
Expand Up @@ -35,6 +35,7 @@ char_code
char_conversion
clause
close
coinductive
compare
complements
complements_object
Expand All @@ -44,9 +45,9 @@ context
copy_term
cos
create_category
create_logtalk_flag
create_object
create_protocol
create_logtalk_flag
current_category
current_char_conversion
current_event
Expand All @@ -61,15 +62,18 @@ current_protocol
define_events
discontiguous
div
domain_error
dynamic
elif
else
encoding
ensure_loaded
endif
end_category
end_object
end_protocol
ensure_loaded
evaluation_error
existence_error
exp
expand_goal
expand_term
Expand Down Expand Up @@ -106,6 +110,7 @@ info
initialization
instantiates
instantiates_class
instantiation_error
integer
keysort
log
Expand All @@ -115,19 +120,18 @@ logtalk_load
logtalk_load_context
logtalk_make
max
meta_predicate
meta_non_terminal
meta_predicate
min
mod
mode
multifile
coinductive
nl
nonvar
number
numbervars
number_chars
number_codes
numbervars
object
object_property
once
Expand All @@ -137,6 +141,7 @@ parameter
peek_byte
peek_char
peek_code
permission_error
phrase
predicate_property
private
Expand All @@ -152,6 +157,8 @@ read_term
reexport
rem
repeat
representation_error
resource_error
retract
retractall
round
Expand Down Expand Up @@ -179,24 +186,25 @@ term_variables
this
threaded
threaded_call
threaded_exit
threaded_ignore
threaded_notify
threaded_once
threaded_peek
threaded_wait
threaded_engine
threaded_engine_create
threaded_engine_destroy
threaded_engine_self
threaded_engine_fetch
threaded_engine_next
threaded_engine_next_reified
threaded_engine_yield
threaded_engine_post
threaded_engine_fetch
threaded_engine_self
threaded_engine_yield
threaded_exit
threaded_ignore
threaded_notify
threaded_once
threaded_peek
threaded_wait
throw
true
truncate
type_error
unify_with_occurs_check
uses
use_module
Expand Down
1 change: 1 addition & 0 deletions coding/pygments/logtalk.py
Expand Up @@ -73,6 +73,7 @@ class LogtalkLexer(RegexLexer):
# Control constructs
(r'(ca(ll|tch)|throw)(?=[(])', Keyword),
(r'(fa(il|lse)|true)\b', Keyword),
(r'(instantiation|type|domain|existence|permission|representation|evaluation|resource)_error(?=[(])', Keyword),
# All solutions
(r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
# Multi-threading predicates
Expand Down
1 change: 1 addition & 0 deletions coding/rouge/lib/rouge/lexers/logtalk.rb
Expand Up @@ -62,6 +62,7 @@ def self.analyze_text(text)
# Control constructs
rule /(call|catch|throw)(?=[(])/, Keyword
rule /(fail|false|true)\b/, Keyword
rule /(instantiation_error|type_error|domain_error|existence_error|permission_error|representation_error|evaluation_error|resource_error)(?=[(])/, Keyword
# All solutions
rule /(bagof|setof|findall|forall)(?=[(])/, Keyword
# Multi-threading meta-predicates
Expand Down
14 changes: 11 additions & 3 deletions coding/rouge/spec/visual/samples/logtalk
Expand Up @@ -30,9 +30,9 @@ comment
extends(parent)).

:- info([
version is 1.36,
version is 1.37,
author is 'Paulo Moura',
date is 2017/06/29,
date is 2017/11/13,
comment is 'Sample prototype for testing syntax coloring.'
]).

Expand Down Expand Up @@ -181,7 +181,15 @@ comment

exception_methods :-
catch(Goal, Error, Catcher),
throw(Error).
throw(Error),
instantiation_error,
type_error(Type, Culprit),
domain_error(Domain, Culprit),
existence_error(Thing, Culprit),
permission_error(Operation, Permission, Culprit),
representation_error(Flag),
evaluation_error(Exception),
resource_error(Resource).

all_solutions_methods :-
bagof(Term, Goal, List),
Expand Down
2 changes: 1 addition & 1 deletion coding/shjs/sh_logtalk.js
Expand Up @@ -24,7 +24,7 @@ sh_languages['logtalk'] = [
4
],
[
/\b(?:abolish|c(?:urrent|reate))_(?:object|protocol|category)(?=\()|\b(?:object|protocol|category)_property(?=\()|\bco(?:mplements_object|nforms_to_protocol)(?=\()|\bextends_(?:object|protocol|category)(?=\()|\bimp(?:lements_protocol|orts_category)(?=\()|\b(?:instantiat|specializ)es_class(?=\()|\b(?:current_event|(?:abolish|define)_events)(?=\()|\b(?:create|current|set)_logtalk_flag(?=\()|\blogtalk_(?:compile|l(?:oad|oad_context|ibrary_path)|make)(?=\()|\b(?:logtalk_make)\b|\b(?:after|before)(?=\()|\bforward(?=\()|\b(?:context|parameter|this|se(?:lf|nder))(?=\()|\b(?:current_predicate|predicate_property)(?=\()|\b(?:expand_(?:goal|term)|(?:goal|term)_expansion|phrase)(?=\()|\b(?:clause|retract(?:all)?)(?=\()|\ba(?:bolish|ssert(?:a|z))(?=\()|\b(?:ca(?:ll|tch)|throw)(?=\()|\b(?:(?:bag|set)of|f(?:ind|or)all)(?=\()|\bthreaded(?:_(?:call|once|ignore|exit|peek|wait|notify))?(?=\()|\bthreaded_engine(?:_(?:create|destroy|self|next|next_reified|yield|post|fetch))?(?=\()|\b(subsumes_term|unify_with_occurs_check)(?=\()|\b(?:functor|arg|copy_term|numbervars|term_variables)(?=\()|\b(?:div|rem|m(?:ax|in|od)|abs|sign)(?=\()|\b(?:float_(?:integer|fractional)_part|float)(?=\()|\b(?:floor|t(?:an|runcate)|round|ceiling|xor)(?=\()|\b(?:cos|a(?:cos|sin|tan|tan2)|exp|log|s(?:in|qrt))(?=\()|\b(?:var|atom(?:ic)?|integer|float|c(?:allable|ompound)|n(?:onvar|umber)|ground|acyclic_term)(?=\()|\bcompare(?=\()|\b(?:curren|se)t_(?:in|out)put(?=\()|\b(?:open|close)(?=\()|\bflush_output(?=\()|\b(?:flush_output|at_end_of_stream)\b|\b(?:stream_property|at_end_of_stream|set_stream_position)(?=\()|\b(?:get|p(?:eek|ut))_(?:byte|c(?:har|ode))(?=\()|\bnl(?=\()|\b(?:nl)\b|\b(?:read(?:_term)?)(?=\()|\b(?:write(?:q|_(?:canonical|term))?)(?=\()|\b(?:op|current_op)(?=\()|\b(?:(?:current_)?char_conversion)(?=\()|\batom_(?:length|c(?:hars|o(?:ncat|des)))(?=\()|\b(?:char_code|sub_atom)(?=\()|\bnumber_(?:c(?:har|ode)s)(?=\()|\b(?:set|current)_prolog_flag(?=\()|\bhalt(?=\()|\b(?:halt)\b|\b(?:ignore|once)(?=\()|\b(?:(?:key)?sort)(?=\()|\b(?:true|fa(?:il|lse)|repeat)\b|\b(?:e|pi|as|is|rem|mod|div)\b/g,
/\b(?:abolish|c(?:urrent|reate))_(?:object|protocol|category)(?=\()|\b(?:object|protocol|category)_property(?=\()|\bco(?:mplements_object|nforms_to_protocol)(?=\()|\bextends_(?:object|protocol|category)(?=\()|\bimp(?:lements_protocol|orts_category)(?=\()|\b(?:instantiat|specializ)es_class(?=\()|\b(?:current_event|(?:abolish|define)_events)(?=\()|\b(?:create|current|set)_logtalk_flag(?=\()|\blogtalk_(?:compile|l(?:oad|oad_context|ibrary_path)|make)(?=\()|\b(?:logtalk_make)\b|\b(?:after|before)(?=\()|\bforward(?=\()|\b(?:context|parameter|this|se(?:lf|nder))(?=\()|\b(?:current_predicate|predicate_property)(?=\()|\b(?:expand_(?:goal|term)|(?:goal|term)_expansion|phrase)(?=\()|\b(?:clause|retract(?:all)?)(?=\()|\ba(?:bolish|ssert(?:a|z))(?=\()|\b(?:ca(?:ll|tch)|throw)(?=\()|\b(?:instantiation|type|domain|existence|permission|representation|evaluation|resource)_error(?=\()|\b(?:(?:bag|set)of|f(?:ind|or)all)(?=\()|\bthreaded(?:_(?:call|once|ignore|exit|peek|wait|notify))?(?=\()|\bthreaded_engine(?:_(?:create|destroy|self|next|next_reified|yield|post|fetch))?(?=\()|\b(subsumes_term|unify_with_occurs_check)(?=\()|\b(?:functor|arg|copy_term|numbervars|term_variables)(?=\()|\b(?:div|rem|m(?:ax|in|od)|abs|sign)(?=\()|\b(?:float_(?:integer|fractional)_part|float)(?=\()|\b(?:floor|t(?:an|runcate)|round|ceiling|xor)(?=\()|\b(?:cos|a(?:cos|sin|tan|tan2)|exp|log|s(?:in|qrt))(?=\()|\b(?:var|atom(?:ic)?|integer|float|c(?:allable|ompound)|n(?:onvar|umber)|ground|acyclic_term)(?=\()|\bcompare(?=\()|\b(?:curren|se)t_(?:in|out)put(?=\()|\b(?:open|close)(?=\()|\bflush_output(?=\()|\b(?:flush_output|at_end_of_stream)\b|\b(?:stream_property|at_end_of_stream|set_stream_position)(?=\()|\b(?:get|p(?:eek|ut))_(?:byte|c(?:har|ode))(?=\()|\bnl(?=\()|\b(?:nl)\b|\b(?:read(?:_term)?)(?=\()|\b(?:write(?:q|_(?:canonical|term))?)(?=\()|\b(?:op|current_op)(?=\()|\b(?:(?:current_)?char_conversion)(?=\()|\batom_(?:length|c(?:hars|o(?:ncat|des)))(?=\()|\b(?:char_code|sub_atom)(?=\()|\bnumber_(?:c(?:har|ode)s)(?=\()|\b(?:set|current)_prolog_flag(?=\()|\bhalt(?=\()|\b(?:halt)\b|\b(?:ignore|once)(?=\()|\b(?:(?:key)?sort)(?=\()|\b(?:true|fa(?:il|lse)|repeat)\b|\b(?:e|pi|as|is|rem|mod|div)\b/g,
'sh_keyword',
-1
],
Expand Down
14 changes: 11 additions & 3 deletions coding/shjs/source.html
Expand Up @@ -43,9 +43,9 @@
extends(parent)).

:- info([
version is 1.36,
version is 1.37,
author is &#x27;Paulo Moura&#x27;,
date is 2017/06/29,
date is 2017/11/13,
comment is &#x27;Sample prototype for testing syntax coloring.&#x27;]).

:- built_in.
Expand Down Expand Up @@ -193,7 +193,15 @@

exception_methods :-
catch(Goal, Error, Catcher),
throw(Error).
throw(Error),
instantiation_error,
type_error(Type, Culprit),
domain_error(Domain, Culprit),
existence_error(Thing, Culprit),
permission_error(Operation, Permission, Culprit),
representation_error(Flag),
evaluation_error(Exception),
resource_error(Resource).

all_solutions_methods :-
bagof(Term, Goal, List),
Expand Down
3 changes: 2 additions & 1 deletion coding/source-highlight/logtalk.lang
@@ -1,7 +1,7 @@
# highlighting for Logtalk source files (http://logtalk.org/)
#
# written by Paulo Moura (pmoura@logtalk.org)
# last revised on June 29, 2017
# last revised on November 13, 2017

comment start "%"
comment delim "/*" "*/" multiline nested
Expand Down Expand Up @@ -31,6 +31,7 @@ keyword = '\<(after|before)(?=\()',
'\<(clause|retract(all)?)(?=\()',
'\<a(bolish|ssert(a|z))(?=\()',
'\<(ca(ll|tch)|throw)(?=\()',
'\<(instantiation|type|domain|existence|permission|representation|evaluation|resource)_error(?=\()',
'\<((bag|set)of|f(ind|or)all)(?=\()',
'\<threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=\()',
'\<threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?(?=\()',
Expand Down

0 comments on commit c29fac5

Please sign in to comment.