summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Moura <pmoura@logtalk.org>2019-11-24 15:33:28 +0000
committerGeorg Brandl <georg@python.org>2019-11-25 12:12:05 +0100
commit36860f10fc7993be03a3ee35fb6bb1304411092a (patch)
tree47abf9e998f29959ab4d8118c6fdf3f20c44d3aa
parent612fb2b33d6f48965661e53c6a88ec78b5dd54e3 (diff)
downloadpygments-git-36860f10fc7993be03a3ee35fb6bb1304411092a.tar.gz
Update Logtalk lexer for the latest language specification
-rw-r--r--pygments/lexers/prolog.py47
1 files changed, 24 insertions, 23 deletions
diff --git a/pygments/lexers/prolog.py b/pygments/lexers/prolog.py
index 8dbbc6d4..70783625 100644
--- a/pygments/lexers/prolog.py
+++ b/pygments/lexers/prolog.py
@@ -107,19 +107,19 @@ class LogtalkLexer(RegexLexer):
(r'\n', Text),
(r'\s+', Text),
# Numbers
- (r"0'.", Number),
+ (r"0'[\\]?.", Number),
(r'0b[01]+', Number.Bin),
(r'0o[0-7]+', Number.Oct),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
# Variables
- (r'([A-Z_]\w*)', Name.Variable),
+ (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
# Event handlers
(r'(after|before)(?=[(])', Keyword),
# Message forwarding handler
(r'forward(?=[(])', Keyword),
# Execution-context methods
- (r'(parameter|this|se(lf|nder))(?=[(])', Keyword),
+ (r'(context|parameter|this|se(lf|nder))(?=[(])', Keyword),
# Reflection
(r'(current_predicate|predicate_property)(?=[(])', Keyword),
# DCGs and term expansion
@@ -135,20 +135,23 @@ class LogtalkLexer(RegexLexer):
# Events
(r'(current_event|(abolish|define)_events)(?=[(])', Keyword),
# Flags
- (r'(current|set)_logtalk_flag(?=[(])', Keyword),
+ (r'(create|current|set)_logtalk_flag(?=[(])', Keyword),
# Compiling, loading, and library paths
- (r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make)(?=[(])', Keyword),
+ (r'logtalk_(compile|l(ibrary_path|oad|oad_context)|make(_target_action)?)(?=[(])', Keyword),
(r'\blogtalk_make\b', Keyword),
# Database
(r'(clause|retract(all)?)(?=[(])', Keyword),
(r'a(bolish|ssert(a|z))(?=[(])', Keyword),
# Control constructs
(r'(ca(ll|tch)|throw)(?=[(])', Keyword),
- (r'(fa(il|lse)|true)\b', Keyword),
+ (r'(fa(il|lse)|true|(instantiation|system)_error)\b', Keyword),
+ (r'(type|domain|existence|permission|representation|evaluation|resource|syntax)_error(?=[(])', Keyword),
# All solutions
(r'((bag|set)of|f(ind|or)all)(?=[(])', Keyword),
- # Multi-threading meta-predicates
- (r'threaded(_(call|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword),
+ # Multi-threading predicates
+ (r'threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?(?=[(])', Keyword),
+ # Engine predicates
+ (r'threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?(?=[(])', Keyword),
# Term unification
(r'(subsumes_term|unify_with_occurs_check)(?=[(])', Keyword),
# Term creation and decomposition
@@ -160,8 +163,7 @@ class LogtalkLexer(RegexLexer):
# Other arithmetic functors
(r'(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=[(])', Keyword),
# Term testing
- (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|'
- r'ground|acyclic_term)(?=[(])', Keyword),
+ (r'(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term)(?=[(])', Keyword),
# Term comparison
(r'compare(?=[(])', Keyword),
# Stream selection and control
@@ -226,10 +228,10 @@ class LogtalkLexer(RegexLexer):
(r'\^', Operator),
# Strings
(r'"(\\\\|\\"|[^"])*"', String),
- # Ponctuation
+ # Punctuation
(r'[()\[\],.|]', Text),
# Atoms
- (r"[a-z]\w*", Text),
+ (r"[a-z][a-zA-Z0-9_]*", Text),
(r"'", String, 'quoted_atom'),
],
@@ -244,36 +246,35 @@ class LogtalkLexer(RegexLexer):
'directive': [
# Conditional compilation directives
(r'(el)?if(?=[(])', Keyword, 'root'),
- (r'(e(lse|ndif))[.]', Keyword, 'root'),
+ (r'(e(lse|ndif))(?=[.])', Keyword, 'root'),
# Entity directives
(r'(category|object|protocol)(?=[(])', Keyword, 'entityrelations'),
- (r'(end_(category|object|protocol))[.]', Keyword, 'root'),
+ (r'(end_(category|object|protocol))(?=[.])', Keyword, 'root'),
# Predicate scope directives
(r'(public|protected|private)(?=[(])', Keyword, 'root'),
# Other directives
(r'e(n(coding|sure_loaded)|xport)(?=[(])', Keyword, 'root'),
(r'in(clude|itialization|fo)(?=[(])', Keyword, 'root'),
- (r'(built_in|dynamic|synchronized|threaded)[.]', Keyword, 'root'),
- (r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|'
- r's(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
+ (r'(built_in|dynamic|synchronized|threaded)(?=[.])', Keyword, 'root'),
+ (r'(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|s(et_(logtalk|prolog)_flag|ynchronized))(?=[(])', Keyword, 'root'),
(r'op(?=[(])', Keyword, 'root'),
(r'(c(alls|oinductive)|module|reexport|use(s|_module))(?=[(])', Keyword, 'root'),
- (r'[a-z]\w*(?=[(])', Text, 'root'),
- (r'[a-z]\w*[.]', Text, 'root'),
+ (r'[a-z][a-zA-Z0-9_]*(?=[(])', Text, 'root'),
+ (r'[a-z][a-zA-Z0-9_]*(?=[.])', Text, 'root'),
],
'entityrelations': [
(r'(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])', Keyword),
# Numbers
- (r"0'.", Number),
+ (r"0'[\\]?.", Number),
(r'0b[01]+', Number.Bin),
(r'0o[0-7]+', Number.Oct),
(r'0x[0-9a-fA-F]+', Number.Hex),
(r'\d+\.?\d*((e|E)(\+|-)?\d+)?', Number),
# Variables
- (r'([A-Z_]\w*)', Name.Variable),
+ (r'([A-Z_][a-zA-Z0-9_]*)', Name.Variable),
# Atoms
- (r"[a-z]\w*", Text),
+ (r"[a-z][a-zA-Z0-9_]*", Text),
(r"'", String, 'quoted_atom'),
# Strings
(r'"(\\\\|\\"|[^"])*"', String),
@@ -281,7 +282,7 @@ class LogtalkLexer(RegexLexer):
(r'([)]\.)', Text, 'root'),
# Scope operator
(r'(::)', Operator),
- # Ponctuation
+ # Punctuation
(r'[()\[\],.|]', Text),
# Comments
(r'%.*?\n', Comment),