[Github-comments] [geany/geany] Add Prolog filetype support (PR #3171)

Robert Di Pardo notifications at github.com
Thu Apr 28 07:31:33 UTC 2022


> > It would be ideal if @ were also recognized as a SWI-Prolog operator [. . .]
>
> Done.

One more thing. SWI-Prolog [uniquely][1] allows backticks to delimit [string literals][0]:

    ?- string_chars(`abc`, Chars).
    Chars = [a, b, c].

I've compared and Vim treats every delimited character sequence as an atom, no matter what the delimiter is, so nothing to be jealous of. But since our lexer already gives a dedicated style to strings, the difference will be apparent:

![geany-pl-sans-bkqouts-himbeere](https://user-images.githubusercontent.com/59004801/165697784-f4c0e8da-5a4f-432b-b2ab-f3c11579a1c5.png)

I suppose this means yet another lexer property, like this?

~~~diff
diff --git a/scintilla/lexilla/lexers/LexVisualProlog.cxx b/scintilla/lexilla/lexers/LexVisualProlog.cxx
index 72a75882b..4eb5c2ec9 100644
--- a/scintilla/lexilla/lexers/LexVisualProlog.cxx
+++ b/scintilla/lexilla/lexers/LexVisualProlog.cxx
@@ -49,8 +49,10 @@ using namespace Lexilla;
 // Options used for LexerVisualProlog
 struct OptionsVisualProlog {
     bool verbatimStrings;
+    bool backQuotedStrings;
     OptionsVisualProlog() {
         verbatimStrings = true;
+        backQuotedStrings = false;
     }
 };

@@ -66,7 +68,8 @@ struct OptionSetVisualProlog : public OptionSet<OptionsVisualProlog> {
     OptionSetVisualProlog() {
         DefineProperty("lexer.visualprolog.verbatim.strings", &OptionsVisualProlog::verbatimStrings,
             "Set to 0 to disable highlighting verbatim strings using '@'.");
-
+        DefineProperty("lexer.visualprolog.backquoted.strings", &OptionsVisualProlog::backQuotedStrings,
+            "Set to 1 to enable using back quotes (``) to delimit strings.");
         DefineWordListSets(visualPrologWordLists);
     }
 };
@@ -447,6 +450,9 @@ void SCI_METHOD LexerVisualProlog::Lex(Sci_PositionU startPos, Sci_Position leng
             } else if (sc.Match('"')) {
                 closingQuote = '"';
                 sc.SetState(SCE_VISUALPROLOG_STRING);
+            } else if (options.backQuotedStrings && sc.Match('`')) {
+                closingQuote = '`';
+                sc.SetState(SCE_VISUALPROLOG_STRING);
             } else if (sc.Match('#')) {
                 sc.SetState(SCE_VISUALPROLOG_KEY_DIRECTIVE);
             } else if (isoperator(static_cast<char>(sc.ch)) || sc.Match('\\')) {

~~~

[0]: https://www.swi-prolog.org/pldoc/man?section=string#:~:text=back-quoted%20text%20(as%20in%20%60text%60)%20is%20mapped%20to%20a%20list%20of%20character%20codes
[1]: https://wiki.visual-prolog.com/index.php?title=Language_Reference/Built-in_entities/Domains#string


-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3171#issuecomment-1111846687
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3171/c1111846687 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20220428/2f74326c/attachment.htm>


More information about the Github-comments mailing list